From: David Levine Date: Mon, 21 Jan 2013 04:22:17 +0000 (-0600) Subject: Replaced hard-coded value with MAX_DELIMITER_SIZE in m_getfld.c. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/8664e81329d0811d0b0f35521a850b74ac276da3?hp=-c Replaced hard-coded value with MAX_DELIMITER_SIZE in m_getfld.c. --- 8664e81329d0811d0b0f35521a850b74ac276da3 diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 59b49677..9a95fb89 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -207,12 +207,12 @@ static unsigned char *matchc(int, char *, int, char *); * * MSG_INPUT_SIZE is the size of the buffer. * MAX_DELIMITER_SIZE is the maximum size of the delimiter used to - * separate messages in a maildrop, such as mbox "\nFrom ". + * separate messages in a maildrop, such as mbox "From ". * * Some of the tests in the test suite assume a MSG_INPUT_SIZE * of 8192. */ #define MSG_INPUT_SIZE (BUFSIZ >= 1024 ? BUFSIZ : 1024) -#define MAX_DELIMITER_SIZE 32 +#define MAX_DELIMITER_SIZE 5 struct m_getfld_state { unsigned char msg_buf[2 * MSG_INPUT_SIZE + MAX_DELIMITER_SIZE]; @@ -702,6 +702,7 @@ m_unknown(m_getfld_state_t s, FILE *iob) char text[MAX_DELIMITER_SIZE]; register char *cp; register char *delimstr; + unsigned int i; enter_getfld (s, iob); @@ -720,13 +721,13 @@ m_unknown(m_getfld_state_t s, FILE *iob) s->msg_style = MS_UNKNOWN; - for (c = 0, cp = text; c < 5; ++c, ++cp) { + for (i = 0, cp = text; i < sizeof text; ++i, ++cp) { if ((*cp = Getc (s)) == EOF) { break; } } - if (c == 5 && strncmp (text, "From ", 5) == 0) { + if (i == sizeof text && strncmp (text, "From ", sizeof text) == 0) { s->msg_style = MS_MBOX; delimstr = "\nFrom "; while ((c = Getc (s)) != '\n' && c >= 0) continue;