Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/isrv_identd.c

    r3232 r3621  
    1919
    2020#include "libbb.h"
     21#include "common_bufsiz.h"
    2122#include <syslog.h>
    2223#include "isrv.h"
     
    2627typedef struct identd_buf_t {
    2728    int pos;
    28     int fd_flag;
    29     char buf[64 - 2*sizeof(int)];
     29    char buf[64 - sizeof(int)];
    3030} identd_buf_t;
    3131
     
    4343        return peer; /* failure, unregister peer */
    4444
    45     buf->fd_flag = fcntl(fd, F_GETFL) | O_NONBLOCK;
     45    ndelay_on(fd);
    4646    isrv_want_rd(state, fd);
    4747    return 0;
     
    5252    identd_buf_t *buf = *paramp;
    5353    char *cur, *p;
    54     int retval = 0; /* session is ok (so far) */
    5554    int sz;
    5655
    5756    cur = buf->buf + buf->pos;
    5857
    59     if (buf->fd_flag & O_NONBLOCK)
    60         fcntl(fd, F_SETFL, buf->fd_flag);
    61     sz = safe_read(fd, cur, sizeof(buf->buf) - buf->pos);
     58    sz = safe_read(fd, cur, sizeof(buf->buf) - 1 - buf->pos);
    6259
    6360    if (sz < 0) {
    6461        if (errno != EAGAIN)
    65             goto term; /* terminate this session if !EAGAIN */
    66         goto ok;
     62            goto term;
     63        return 0; /* "session is ok" */
    6764    }
    6865
     
    7269    if (p)
    7370        *p = '\0';
    74     if (!p && sz && buf->pos <= (int)sizeof(buf->buf))
    75         goto ok;
     71    if (!p && sz)
     72        return 0;  /* "session is ok" */
     73
    7674    /* Terminate session. If we are in server mode, then
    7775     * fd is still in nonblocking mode - we never block here */
    78     if (fd == 0) fd++; /* inetd mode? then write to fd 1 */
     76    if (fd == 0)
     77        fd++; /* inetd mode? then write to fd 1 */
    7978    fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser);
     79    /*
     80     * Why bother if we are going to close fd now anyway?
     81     * if (server)
     82     *  ndelay_off(fd);
     83     */
    8084 term:
    8185    free(buf);
    82     retval = 1; /* terminate */
    83  ok:
    84     if (buf->fd_flag & O_NONBLOCK)
    85         fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK);
    86     return retval;
     86    return 1; /* "terminate" */
    8787}
    8888
     
    9696    identd_buf_t *buf = xzalloc(sizeof(*buf));
    9797    /* buf->pos = 0; - xzalloc did it */
    98     /* We do NOT want nonblocking I/O here! */
    99     /* buf->fd_flag = 0; - xzalloc did it */
    10098    do
    10199        alarm(TIMEOUT);
     100        /* Note: we do NOT want nonblocking I/O here! */
    102101    while (do_rd(0, (void*)&buf) == 0);
    103102}
     
    118117    int fd;
    119118
     119    setup_common_bufsiz();
     120
    120121    opt = getopt32(argv, "fiwb:", &bind_address);
    121122    strcpy(bogouser, "nobody");
    122123    if (argv[optind])
    123         strncpy(bogouser, argv[optind], sizeof(bogouser));
     124        strncpy(bogouser, argv[optind], COMMON_BUFSIZE - 1);
    124125
    125126    /* Daemonize if no -f and no -i and no -w */
Note: See TracChangeset for help on using the changeset viewer.