]> diplodocus.org Git - nmh/commitdiff
m_getfld: Shorten fdelimlen by one; it was too long.
authorRalph Corderoy <ralph@inputplus.co.uk>
Fri, 11 Nov 2016 23:23:11 +0000 (23:23 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Fri, 11 Nov 2016 23:23:11 +0000 (23:23 +0000)
The fdelimlen bytes starting at fdelim included a NUL at the end, e.g. 7
for "\nFrom \0".  Other code seems not to expect this and has
conditional bits to work around it, perhaps without understanding why.
All the tests still pass, including with valgrind.

sbr/m_getfld.c

index 5c5b4a3..b4019b0 100644 (file)
@@ -817,7 +817,7 @@ m_unknown(m_getfld_state_t *gstate, FILE *iob)
     *s->fdelim = '\n';
     s->msg_delim = s->fdelim+1;
     s->edelim = s->msg_delim+1;
     *s->fdelim = '\n';
     s->msg_delim = s->fdelim+1;
     s->edelim = s->msg_delim+1;
-    s->fdelimlen = c + 1;
+    s->fdelimlen = c;
     s->edelimlen = c - 1; /* == strlen (delimstr) */
     strcpy (s->msg_delim, delimstr);
     s->delimend = s->msg_delim + s->edelimlen;
     s->edelimlen = c - 1; /* == strlen (delimstr) */
     strcpy (s->msg_delim, delimstr);
     s->delimend = s->msg_delim + s->edelimlen;