pfelt-Urct4Ww6//Pz1n+
2010-12-31 03:51:43 UTC
my box would not read the whole buffer out with a single read(). this i
think fixes that. seems to work on my lappy.
my original thoughts it was getting encoded wrong were incorrect. it's
just how gdb prints when there are non printable ascii chars in the
string....
Index: mail.c
===================================================================
--- mail.c (revision 1323)
+++ mail.c (working copy)
@@ -146,35 +146,41 @@
// child.
close(commsPipe[1]);
- int nbytes = read(commsPipe[0], readbuffer, sizeof(readbuffer));
- // if we don't get anything back, it all failed.
- if (nbytes < 1) {
- goto finish;
- }
-
waitpid(childpid, NULL, 0);
-
- char *responses[] = {0, 0};
- int response = 1;
- char *ptr = responses[0] = readbuffer;
- while (ptr <= readbuffer + nbytes) {
- if (*ptr == '\1') {
- *ptr = '\0';
- if (response == 2) {
- // we have a key/value pair
- response = 0;
- if (strlen(responses[1]) > 0)
- SetDocProp(client, document,
responses[0], responses[1]);
- if (strcmp(responses[0],
"nmap.mail.subject") == 0) {
- message_subject =
MemStrdup(responses[1]);
+
+ int nbytes;
+ while(1) {
+ nbytes = read(commsPipe[0], readbuffer, sizeof(readbuffer));
+ // if we don't get anything back, it all failed.
+ if (nbytes < 0) {
+ goto finish;
+ } else if (nbytes == 0) {
+ break;
+ }
+
+ char *responses[] = {0, 0};
+ int response = 1;
+ char *ptr = responses[0] = readbuffer;
+
+ while (ptr <= readbuffer + nbytes) {
+ if (*ptr == '\1') {
+ *ptr = '\0';
+ if (response == 2) {
+ // we have a key/value pair
+ response = 0;
+ if (strlen(responses[1]) > 0)
+ SetDocProp(client,
document, responses[0], responses[1]);
+ if (strcmp(responses[0],
"nmap.mail.subject") == 0) {
+ message_subject =
MemStrdup(responses[1]);
+ }
}
+ responses[response] = ptr + 1;
+ response++;
}
- responses[response] = ptr + 1;
- response++;
+ ptr++;
}
- ptr++;
}
-
+
// now, see if we can find a matching conversation
if (message_subject) {
conversation_data.subject = message_subject;
think fixes that. seems to work on my lappy.
my original thoughts it was getting encoded wrong were incorrect. it's
just how gdb prints when there are non printable ascii chars in the
string....
Index: mail.c
===================================================================
--- mail.c (revision 1323)
+++ mail.c (working copy)
@@ -146,35 +146,41 @@
// child.
close(commsPipe[1]);
- int nbytes = read(commsPipe[0], readbuffer, sizeof(readbuffer));
- // if we don't get anything back, it all failed.
- if (nbytes < 1) {
- goto finish;
- }
-
waitpid(childpid, NULL, 0);
-
- char *responses[] = {0, 0};
- int response = 1;
- char *ptr = responses[0] = readbuffer;
- while (ptr <= readbuffer + nbytes) {
- if (*ptr == '\1') {
- *ptr = '\0';
- if (response == 2) {
- // we have a key/value pair
- response = 0;
- if (strlen(responses[1]) > 0)
- SetDocProp(client, document,
responses[0], responses[1]);
- if (strcmp(responses[0],
"nmap.mail.subject") == 0) {
- message_subject =
MemStrdup(responses[1]);
+
+ int nbytes;
+ while(1) {
+ nbytes = read(commsPipe[0], readbuffer, sizeof(readbuffer));
+ // if we don't get anything back, it all failed.
+ if (nbytes < 0) {
+ goto finish;
+ } else if (nbytes == 0) {
+ break;
+ }
+
+ char *responses[] = {0, 0};
+ int response = 1;
+ char *ptr = responses[0] = readbuffer;
+
+ while (ptr <= readbuffer + nbytes) {
+ if (*ptr == '\1') {
+ *ptr = '\0';
+ if (response == 2) {
+ // we have a key/value pair
+ response = 0;
+ if (strlen(responses[1]) > 0)
+ SetDocProp(client,
document, responses[0], responses[1]);
+ if (strcmp(responses[0],
"nmap.mail.subject") == 0) {
+ message_subject =
MemStrdup(responses[1]);
+ }
}
+ responses[response] = ptr + 1;
+ response++;
}
- responses[response] = ptr + 1;
- response++;
+ ptr++;
}
- ptr++;
}
-
+
// now, see if we can find a matching conversation
if (message_subject) {
conversation_data.subject = message_subject;