[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Here are possible patches affecting hobbitfetch
- To: hobbit (at) hswn.dk
- Subject: Here are possible patches affecting hobbitfetch
- From: Cade Robinson <cade.robinson (at) gmail.com>
- Date: Mon, 15 Feb 2010 10:21:05 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=YfGWyAoKPLr/geg9LF/TCOqnBy/3gxWTyJjEXr+eyNw=; b=M0z18T3KQT3cW9ci++3afGkTzB++R5xtzpLFF/Y/ebaIkC88BkYMKkKnneAJI3tQbE YMc9Bi2rAVmndN5vNi31JmVNcGVaXANVQ+pOzzCYWjJWcm2Xudv1GV1KfgJZ64R6Peyh ztxohbjWLZimaSiHqyxfaMwEaRyATkCYtHgtI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=nff4Epzp/l/bdw5IPNrwK0MtoiecVUtJ0AT7imsEihycs8t+WgiPjAIIvWS/7NbpXw eGCJZZBycsKV/rJ05B0I8i8CKWaUuLWYD1YYl15IdTHhIIYuua/tF3D9Wff7va0wGef+ a2efwJIt28ECCXEGroZjOuFaKcPp+MWBW7e1c=
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) {