summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-08-18 06:27:24 +0000
committerLuke Leighton <lkcl@samba.org>2000-08-18 06:27:24 +0000
commit7e5fd8fc2c255b5388a634b18280bb497f82e3ed (patch)
tree426c855ea5616dba2d9baa6dea04f7ab26ae639d /source3
parent0136927ed887fc9c085c667fc59130cb3a13f687 (diff)
downloadsamba-7e5fd8fc2c255b5388a634b18280bb497f82e3ed.tar.gz
samba-7e5fd8fc2c255b5388a634b18280bb497f82e3ed.tar.bz2
samba-7e5fd8fc2c255b5388a634b18280bb497f82e3ed.zip
oops. must return "" string and length zero when strlen(filebuf) == 0
(This used to be commit d3bc7cca99e47ce89035a03022d7c3ec69e01636)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_file.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 50bd85e6e3..e21aafa009 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -217,24 +217,27 @@ int getfileline(void *vp, char *linebuf, int linebuf_size)
*/
linebuf_len = strlen(linebuf);
- if (linebuf_len > 0)
+ if (linebuf_len == 0)
{
- if (linebuf[linebuf_len - 1] != '\n')
+ linebuf[0] = '\0';
+ return 0;
+ }
+
+ if (linebuf[linebuf_len - 1] != '\n')
+ {
+ c = '\0';
+ while (!ferror(fp) && !feof(fp))
{
- c = '\0';
- while (!ferror(fp) && !feof(fp))
+ c = fgetc(fp);
+ if (c == '\n')
{
- c = fgetc(fp);
- if (c == '\n')
- {
- break;
- }
+ break;
}
}
- else
- {
- linebuf[linebuf_len - 1] = '\0';
- }
+ }
+ else
+ {
+ linebuf[linebuf_len - 1] = '\0';
}
#ifdef DEBUG_PASSWORD