#include "fe-auth.h"
#include "libpq-fe.h"
#include "libpq-int.h"
-#include "lib/stringinfo.h"
#include "mb/pg_wchar.h"
#include "pg_config_paths.h"
#include "port/pg_bswap.h"
i;
FILE *f;
char *line;
- StringInfoData linebuf;
+ char buf[1024];
*group_found = false;
return 1;
}
- initStringInfo(&linebuf);
-
- while (pg_get_line_buf(f, &linebuf))
+ while ((line = fgets(buf, sizeof(buf), f)) != NULL)
{
+ int len;
+
linenr++;
- /* ignore whitespace at end of line, especially the newline */
- while (linebuf.len > 0 &&
- isspace((unsigned char) linebuf.data[linebuf.len - 1]))
- linebuf.data[--linebuf.len] = '\0';
+ if (strlen(line) >= sizeof(buf) - 1)
+ {
+ appendPQExpBuffer(errorMessage,
+ libpq_gettext("line %d too long in service file \"%s\"\n"),
+ linenr,
+ serviceFile);
+ result = 2;
+ goto exit;
+ }
- line = linebuf.data;
+ /* ignore whitespace at end of line, especially the newline */
+ len = strlen(line);
+ while (len > 0 && isspace((unsigned char) line[len - 1]))
+ line[--len] = '\0';
/* ignore leading whitespace too */
while (*line && isspace((unsigned char) line[0]))
exit:
fclose(f);
- pfree(linebuf.data);
return result;
}