cygwindropbear

packet.c:98:2: error: 'writebuf' undeclared (first use in this function)


I'm trying to compile dropbear for windows before I compiled it but now that I try to recompile it and format my previous pc, install cygwin and what is necessary but when I execute the make command, it throws me that error. but I do not understand why it says that it is not declared if it is clearly seen there, I would appreciate your help.

ERROR: "packet.c: In function 'write_packet':
packet.c:98:2: error: 'writebuf' undeclared (first use in this function)
  writebuf = (buffer*)examine(&ses.writequeue);"

CODE:
        #ifdef HAVE_WRITEV
        /* 50 is somewhat arbitrary */
        unsigned int iov_count = 50;
        struct iovec iov[50];
    #else
        int len;
        buffer* writebuf;
        int packet_type;
    #endif

        TRACE2(("enter write_packet"))
        dropbear_assert(!isempty(&ses.writequeue));

    #if defined(HAVE_WRITEV) && (defined(IOV_MAX) || defined(UIO_MAXIOV))

        packet_queue_to_iovec(&ses.writequeue, iov, &iov_count);
        /* This may return EAGAIN. The main loop sometimes
        calls write_packet() without bothering to test with select() since
        it's likely to be necessary */
        written = writev(ses.sock_out, iov, iov_count);
        if (written < 0) {
            if (errno == EINTR || errno == EAGAIN) {
                TRACE2(("leave write_packet: EINTR"))
                return;
            } else {
                dropbear_exit("Error writing: %s", strerror(errno));
            }
        }

        packet_queue_consume(&ses.writequeue, written);
        ses.writequeue_len -= written;

        if (written == 0) {
            ses.remoteclosed();
        }

    #else /* No writev () */
        /* Get the next buffer in the queue of encrypted packets to write*/
        writebuf = (buffer*)examine(&ses.writequeue);

        /* The last byte of the buffer is not to be transmitted, but is 
         * a cleartext packet_type indicator */
        packet_type = writebuf->data[writebuf->len-1];
        len = writebuf->len - 1 - writebuf->pos;
        TRACE2(("write_packet type %d len %d/%d", packet_type,
                len, writebuf->len-1))
        dropbear_assert(len > 0);

Solution

  • The problem seems due that the definition protected by a single check

    #ifdef HAVE_WRITEV
    

    while the usage is behind a multiple check

    #if defined(HAVE_WRITEV) && (defined(IOV_MAX) || defined(UIO_MAXIOV))
    

    HAVE_WRITEV is defined in config.h on cygwin, so the definition is skipped but the check for usage fails and writebuf is used. It seems a upstream bug.