mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
getfileline() - line with length of zero -> filebuf[strlen(filebuf)-1]
is NOT ok. (This used to be commit 24e0c8ef70dc59bfaaa113c3d44befbccbcba15f)
This commit is contained in:
parent
7c3ca833e6
commit
40cc8e0df2
@ -217,21 +217,24 @@ int getfileline(void *vp, char *linebuf, int linebuf_size)
|
||||
*/
|
||||
|
||||
linebuf_len = strlen(linebuf);
|
||||
if (linebuf[linebuf_len - 1] != '\n')
|
||||
if (linebuf_len > 0)
|
||||
{
|
||||
c = '\0';
|
||||
while (!ferror(fp) && !feof(fp))
|
||||
if (linebuf[linebuf_len - 1] != '\n')
|
||||
{
|
||||
c = fgetc(fp);
|
||||
if (c == '\n')
|
||||
c = '\0';
|
||||
while (!ferror(fp) && !feof(fp))
|
||||
{
|
||||
break;
|
||||
c = fgetc(fp);
|
||||
if (c == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
linebuf[linebuf_len - 1] = '\0';
|
||||
else
|
||||
{
|
||||
linebuf[linebuf_len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
|
Loading…
x
Reference in New Issue
Block a user