--- acl-2.2.51/setfacl/parse.c.orig 2010-01-22 23:00:28.000000000 +0000 +++ acl-2.2.51/setfacl/parse.c 2011-08-03 17:10:24.000000000 +0000 @@ -419,7 +419,9 @@ 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 *linebuf; + size_t dummy = 0; char *cp; char *p; int comments_read = 0; @@ -449,9 +451,8 @@ if (line) (*line)++; - if (fgets(linebuf, sizeof(linebuf), file) == NULL) + if (getline(&linebuf, &dummy, file) == -1) break; - comments_read = 1; p = strrchr(linebuf, '\0'); @@ -472,8 +473,10 @@ if (*path_p) goto fail; *path_p = (char*)malloc(strlen(cp)+1); - if (!*path_p) - return -1; + if (!*path_p) { + free (linebuf); + return -1; + } strcpy(*path_p, cp); } } else if (strncmp(cp, "owner:", 6) == 0) { @@ -521,14 +524,18 @@ *flags = f; } } - if (ferror(file)) - return -1; + if (ferror(file)) { + free (linebuf); + return -1; + } + free (linebuf); return comments_read; fail: if (path_p && *path_p) { free(*path_p); *path_p = NULL; } + free (linebuf); return -EINVAL; }