summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-08-18 05:56:19 +0000
committerLuke Leighton <lkcl@samba.org>2000-08-18 05:56:19 +0000
commit40cc8e0df2282e8fc8d20735ee351add1ae23644 (patch)
treec9ffdb15cbb02e4050687e98a32b412396c29547
parent7c3ca833e6f3f8bb95c1816e76a148e26841ca59 (diff)
downloadsamba-40cc8e0df2282e8fc8d20735ee351add1ae23644.tar.gz
samba-40cc8e0df2282e8fc8d20735ee351add1ae23644.tar.bz2
samba-40cc8e0df2282e8fc8d20735ee351add1ae23644.zip
getfileline() - line with length of zero -> filebuf[strlen(filebuf)-1]
is NOT ok. (This used to be commit 24e0c8ef70dc59bfaaa113c3d44befbccbcba15f)
-rw-r--r--source3/lib/util_file.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 194fb7ae49..50bd85e6e3 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -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