summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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