]> 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 5c5b4a3a88274646175e993af895e64593bd5282..b4019b0cf7ccc4d31360dffba631c04872d0f725 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;