mdocml: cgi.c makes wrong usage of fgetln(3).

Issue #97 resolved
Takehiko NOZAKI repo owner created an issue

see following code:

    609     while (NULL != (p = fgetln(f, &len))) {
...
    611         for (i = 0; i < (int)len - 1; i++) {
...
    618             if ('\b' == p[i] || '\n' == p[i])
...
    712         if (i == (int)len - 1 && '\n' != p[i])
    713             html_putchar(p[i]);
...

line 611, assume always string is end with '\n' and substruct -1 from len, it is wrong so line 712, try to fix something wrong with this assumotion, it is quit bogus.

and line 618, fgetln(3) never returns string that contains '\n' before len - 1, completely useless check.

Comments (2)

  1. Log in to comment