diff options
author | Stef Walter <stef@memberwebs.com> | 2006-03-29 04:14:02 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2006-03-29 04:14:02 +0000 |
commit | 40bfafee2377c27bc01ffb4bb5e0e868611c6c28 (patch) | |
tree | 2aad22937211bd5e336fae32d7fa21eeb25f4b33 | |
parent | 26a1ea1de4e91abc69c291374e12abbf3ad72130 (diff) |
Handle long lines properly.
-rw-r--r-- | module/bsnmp-regex.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/module/bsnmp-regex.c b/module/bsnmp-regex.c index 4a75a7c..49bda3e 100644 --- a/module/bsnmp-regex.c +++ b/module/bsnmp-regex.c @@ -452,18 +452,14 @@ io_data (int fd, void *user_data) int len; int r, l; - fprintf(stderr, "io data\n"); - ASSERT (fd == conn->fd); line_buffer = conn->line_buffer; len = strlen (line_buffer); ASSERT (len < LINE_LENGTH); -fprintf (stderr, "going to read: "); do { r = read (fd, line_buffer + len, (LINE_LENGTH - 1) - len); -fprintf (stderr, "done: %d\n", r); /* An error, close */ if (r < 0 && errno != EAGAIN) { @@ -483,14 +479,15 @@ fprintf (stderr, "done: %d\n", r); line_buffer[len] = 0; } - /* Break really long lines */ - if (len >= LINE_LENGTH - 1) - line_buffer[len - 1] = '\n'; - for (;;) { t = strchr (line_buffer, '\n'); - if (t == NULL) - break; + if (t == NULL) { + /* Break really long lines */ + if (len >= LINE_LENGTH - 1) + t = line_buffer + len; + else + break; + } /* Break line (also DOS line) */ *t = 0; @@ -516,8 +513,6 @@ io_accept (int fd, void *unused) struct connection *conn; int nfd; -fprintf(stderr, "accepting sock\n"); - nfd = accept (fd, NULL, NULL); if (nfd < 0) { if (errno != EAGAIN || errno != EINTR) |