[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] Here are possible patches affecting hobbitfetch
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] Here are possible patches affecting hobbitfetch
- From: Steinar M. Skúlason <steinarms (at) gmail.com>
- Date: Thu, 18 Feb 2010 13:50:46 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=ZZcC7QVKxcyDF3nUJ3FZ/mD8k6SdwQ/Y2+nXM0P0mtc=; b=KerVGUYTVfNJEKL7Ergl7z3q2Rq0XTb5gPSLJ+RX+n5ElDJYzhLD2LRtlZpthPPgJl SvTg+5RZnJWNtJxuW2BB4ufZJeEQRDrozejJvJiDdp7SUE5sfNWvHYfBusPZtAX61FLy cilw2wp+rRb7xJXr5kcKPdfkzQcD6pgHRlwKQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=JPzy2A6iyR2M9RXjoQ8loeOT5p31tAWAbcyufF4CL04QX9MpDUzkFfzyvgeL0Teti1 F9C8vgsKs77eKGh2AHx+s3+U5QXVnT/cgrv4Auv4SVgh2i251vQrz530L+aMwyy0YcxD oqcPZOyUd42RY7x0Gg2iLP1vEF7ZO6LLJYNdo=
- References: <1266250865.10143.118.camel (at) crobinso.nisc.lan>
Thanks for your effort Cade, I applied your patches on latest from svn -
version 4.3.0
and it has been working for 3days now.
Best Regards,
Steinar M.
On Mon, Feb 15, 2010 at 4:21 PM, Cade Robinson <cade.robinson (at) gmail.com>wrote:
>
>
> I have been having some issues with hobbitfetch and have modified a few
> files to fix them. At least my definition of fixed in that hobbitfetch
> now works - but the way they are fixed may not be right.
>
> include/libbbgen.h
> Change IP_ADDR_STRLEN from 16 to 22.
> The reason is that I was getting reports from IP:port and that is 22
> chars with the trailing NULL. At 16 I was getting multi-source reports
> and the the host shown in "Status message received from" was truncated
> otherwise.
>
> hobbitd/hobbitd.c
> Again related to the above - took out he %16s because my host could be
> 22 chars.
>
> hobbitd/hobbitfetch.c
> Lowered res from 100 to 25 - same as above so it could really be 22. Not
> much of a change but save a bit of mem.
>
> Change the read to read two less bytes than sizeof(buf) and set buf[n-1]
> to NULL. This is in case 8192 bytes are sent/read. Since buf is 8192
> elements long the last element is 8191 not 8192 so buf[n]=\0; when 8192
> bytes are read causes a segfault. I think the same should be done in
> msgcache.c as well but I haven't seen anything over 100 bytes be sent to
> msgcache.
>
>
>
>
> Here are the patches:
> Index: include/libbbgen.h
> ===================================================================
> --- include/libbbgen.h (revision 6223)
> +++ include/libbbgen.h (working copy)
> @@ -27,7 +27,7 @@
> #define STRBUF(buf) (buf->s)
> #define STRBUFLEN(buf) (buf->used)
>
> -#define IP_ADDR_STRLEN 16
> +#define IP_ADDR_STRLEN 22
>
> #include "version.h"
> #include "config.h"
> Index: hobbitd/hobbitd.c
> ===================================================================
> --- hobbitd/hobbitd.c (revision 6223)
> +++ hobbitd/hobbitd.c (working copy)
> @@ -2789,7 +2789,7 @@
> /* Pick out the real sender of this message */
> msgfrom = strstr(currmsg, "\nStatus message
> received from ");
> if (msgfrom) {
> - sscanf(msgfrom, "\nStatus message
> received from %16s\n", sender);
> + sscanf(msgfrom, "\nStatus message
> received from %s\n", sender);
> *msgfrom = '\0';
> }
>
> @@ -2866,7 +2866,7 @@
> else if (strncmp(msg->buf, "status", 6) == 0) {
> msgfrom = strstr(msg->buf, "\nStatus message received
> from ");
> if (msgfrom) {
> - sscanf(msgfrom, "\nStatus message received from
> %16s\n", sender);
> + sscanf(msgfrom, "\nStatus message received from
> %s\n", sender);
> *msgfrom = '\0';
> }
>
> @@ -2907,7 +2907,7 @@
>
> msgfrom = strstr(msg->buf, "\nStatus message received
> from ");
> if (msgfrom) {
> - sscanf(msgfrom, "\nStatus message received from
> %16s\n", sender);
> + sscanf(msgfrom, "\nStatus message received from
> %s\n", sender);
> *msgfrom = '\0';
> }
>
> @@ -3668,7 +3668,7 @@
> if (msgfrom) {
> char *ipline = strstr(msgfrom, "\nClientIP:");
> if (ipline) {
> - sscanf(ipline, "\nClientIP:%16s\n",
> sender);
> + sscanf(ipline, "\nClientIP:%s\n",
> sender);
> }
> }
>
> Index: hobbitd/hobbitfetch.c
> ===================================================================
> --- hobbitd/hobbitfetch.c (revision 6223)
> +++ hobbitd/hobbitfetch.c (working copy)
> @@ -100,7 +100,7 @@
>
> char *addrstring(struct sockaddr_in *addr)
> {
> - static char res[100];
> + static char res[25];
>
> sprintf(res, "%s:%d", inet_ntoa(addr->sin_addr),
> ntohs(addr->sin_port));
> return res;
> @@ -346,7 +346,7 @@
> char buf[8192];
>
> /* Read data from a peer connection (client or server) */
> - n = read(conn->sockfd, buf, sizeof(buf));
> + n = read(conn->sockfd, buf, sizeof(buf)-2);
> if (n == -1) {
> /* Read failure */
> time_t now = gettimer();
> @@ -361,7 +361,7 @@
> /* Save the data */
> dbgprintf("Got %d bytes of data from %s (req %lu)\n",
> n, addrstring(&conn->caddr), conn->seq);
> - buf[n] = '\0';
> + buf[n+1] = '\0';
> addtobuffer(conn->msgbuf, buf);
> }
> else if (n == 0) {
>
>
>
> To unsubscribe from the hobbit list, send an e-mail to
> hobbit-unsubscribe (at) hswn.dk
>
>
>