From: Ralph Corderoy Date: Fri, 11 Nov 2016 23:23:11 +0000 (+0000) Subject: m_getfld: Shorten fdelimlen by one; it was too long. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/36a12f6a1a5a57799e48b23fd5ae47fe2351be68?hp=d0ae0c245cec54166b98cde12f2c42f0c1b6da3a m_getfld: Shorten fdelimlen by one; it was too long. 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. --- diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 5c5b4a3a..b4019b0c 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -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->fdelimlen = c + 1; + s->fdelimlen = c; s->edelimlen = c - 1; /* == strlen (delimstr) */ strcpy (s->msg_delim, delimstr); s->delimend = s->msg_delim + s->edelimlen;