summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-01-19 01:05:11 -0500
committerMike Frysinger <vapier@gentoo.org>2014-01-19 01:08:08 -0500
commit34d5069ab4187aece1b711a86af705ff121ac62d (patch)
tree26bdde427aec18b20d1b13ec8044d88e7af62600 /tools
parent3d615724df45f9d7b3438ce7aa2d4f1704aad7d1 (diff)
downloadacl-34d5069ab4187aece1b711a86af705ff121ac62d.tar.gz
read_acl_{comments,seq}: switch to next_line
Rather than use a fixed length buffer, use next_line. This let's us handle any arbitrary length and avoid the non-portable PATH_MAX. Fixes bug 27388 in the acl tracker.
Diffstat (limited to 'tools')
-rw-r--r--tools/parse.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/tools/parse.c b/tools/parse.c
index 6f30cf5..df69c26 100644
--- a/tools/parse.c
+++ b/tools/parse.c
@@ -419,9 +419,7 @@ read_acl_comments(
bytes for "# file: ". Not a good solution but for now it is the
best I can do without too much impact on the code. [tw]
*/
- char linebuf[(4*PATH_MAX)+9];
- char *cp;
- char *p;
+ char *line, *cp, *p;
int comments_read = 0;
if (path_p)
@@ -449,19 +447,20 @@ read_acl_comments(
if (lineno)
(*lineno)++;
- if (fgets(linebuf, sizeof(linebuf), file) == NULL)
+ line = next_line(file);
+ if (line == NULL)
break;
comments_read = 1;
- p = strrchr(linebuf, '\0');
- while (p > linebuf &&
+ p = strrchr(line, '\0');
+ while (p > line &&
(*(p-1)=='\r' || *(p-1)=='\n')) {
p--;
*p = '\0';
}
- cp = linebuf;
+ cp = line;
SKIP_WS(cp);
if (strncmp(cp, "file:", 5) == 0) {
cp += 5;
@@ -542,20 +541,18 @@ read_acl_seq(
int *lineno,
int *which)
{
- char linebuf[1024];
+ char *line;
const char *cp;
cmd_t cmd;
if (which)
*which = -1;
- for(;;) {
- if (fgets(linebuf, sizeof(linebuf), file) == NULL)
- break;
+ while ((line = next_line(file))) {
if (lineno)
(*lineno)++;
- cp = linebuf;
+ cp = line;
SKIP_WS(cp);
if (*cp == '\0') {
if (!(parse_mode & SEQ_PARSE_MULTI))
@@ -588,7 +585,7 @@ read_acl_seq(
fail:
if (which)
- *which = (cp - linebuf);
+ *which = (cp - line);
return -1;
}