mdocml: manpath.c off-by-one by making wrong usage of fgetln(3)

Issue #98 resolved
Takehiko NOZAKI repo owner created an issue

see following code:

       while (NULL != (p = fgetln(stream, &len))) {
               if (0 == len || '\n' != p[--len])
                       break;
               p[len] = '\0';

if p[len - 1] is not '\n', p[len] = '\0' causes off-by-one buffer overrun, read carefully fgetln(3) manual's CAVEANTS section.

Comments (4)

  1. Takehiko NOZAKI reporter

    and more:

                   if (strncmp(MAN_CONF_KEY, p, keysz))
    

    if p's length(=len) is short than keysz, this compare make overrun too.

  2. Takehiko NOZAKI reporter

    oops,

    if p's length(=len) is short than keysz, this compare make overrun too.
    

    is not correct, strncmp(3) stop with '\0' unlike memcmp(3). so never overrun ;)

  3. Log in to comment