Hi, On Thu, Nov 20, 2014 at 06:24:23PM -0500, Ted Unangst wrote: > [on behalf of reyk] > > Many people want to test the new httpd in OpenBSD 5.6; so we decided > to provide various improvements from -current for 5.6. > See the description below for more details.
[...] > Index: usr.sbin/httpd/httpd.c > =================================================================== > RCS file: /cvs/src/usr.sbin/httpd/httpd.c,v > retrieving revision 1.17 > diff -u -p -r1.17 httpd.c > --- usr.sbin/httpd/httpd.c 5 Aug 2014 15:36:59 -0000 1.17 > +++ usr.sbin/httpd/httpd.c 18 Nov 2014 15:02:54 -0000 [...] > @@ -623,6 +678,40 @@ socket_rlimit(int maxfd) > rl.rlim_cur = MAX(rl.rlim_max, (rlim_t)maxfd); > if (setrlimit(RLIMIT_NOFILE, &rl) == -1) > fatal("socket_rlimit: failed to set resource limit"); > +} > + > +char * > +evbuffer_getline(struct evbuffer *evb) > +{ > + u_int8_t *ptr = EVBUFFER_DATA(evb); > + size_t len = EVBUFFER_LENGTH(evb); > + char *str; > + u_int i; > + > + /* Safe version of evbuffer_readline() */ > + if ((str = get_string(ptr, len)) == NULL) > + return (NULL); > + > + for (i = 0; str[i] != '\0'; i++) { > + if (str[i] == '\r' || str[i] == '\n') > + break; > + } > + > + if (i == len) { > + free(str); > + return (NULL); > + } > + > + str[i] = '\0'; > + > + if ((i + 1) < len) { > + if (ptr[i] == '\r' && ptr[i + 1] == '\n') > + i++; > + } any concern over 'u_int i' vs 'size_t len' type-mismatch? --patrick