diff options
author | Nathan Scott <nathans@sgi.com> | 2005-02-21 02:47:36 +0000 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2005-02-21 02:47:36 +0000 |
commit | 3af9ec3b25013fbec25e53693fa9fe37bff739ca (patch) | |
tree | 9b10d5d41256b6b04b9e781cc21379e735335157 | |
parent | 3f72dbf27deb81bc3ea1c598f400123157562f7c (diff) | |
download | attr-3af9ec3b25013fbec25e53693fa9fe37bff739ca.tar.gz |
setfattr line buffer allocation fix from AndreasG.
Merge of master-melb:xfs-cmds:21572a by kenmcd.
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | doc/CHANGES | 4 | ||||
-rw-r--r-- | setfattr/setfattr.c | 46 |
4 files changed, 46 insertions, 12 deletions
@@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=4 -PKG_REVISION=21 +PKG_REVISION=22 PKG_BUILD=1 diff --git a/debian/changelog b/debian/changelog index 62d3b9d..38bd62f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +attr (2.4.22-1) unstable; urgency=low + + * New upstream release + + -- Nathan Scott <nathans@debian.org> Mon, 21 Feb 2005 08:13:36 +1100 + attr (2.4.21-1) unstable; urgency=low * New upstream release diff --git a/doc/CHANGES b/doc/CHANGES index d8fd08d..fce03ed 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +attr-2.4.22 (21 February 2005) + - Allocate the line buffer dynamically when reading from a file. + This mainly fixes restoring of large attributes. + attr-2.4.21 (31 January 2005) - Replace use of _POSIX_PATH_MAX with the larger PATH_MAX (thanks to Andree Leidenfrost). diff --git a/setfattr/setfattr.c b/setfattr/setfattr.c index 6cf8700..6f5deaa 100644 --- a/setfattr/setfattr.c +++ b/setfattr/setfattr.c @@ -180,17 +180,41 @@ void help(void) char *next_line(FILE *file) { - static char line[PATH_MAX+32], *c; - if (!fgets(line, sizeof(line), file)) - return NULL; - - c = strrchr(line, '\0'); - while (c > line && (*(c-1) == '\n' || - *(c-1) == '\r')) { - c--; - *c = '\0'; - } - return line; + static char *line; + static size_t line_size; + char *c; + int eol = 0; + + if (!line) { + if (high_water_alloc((void **)&line, &line_size, PATH_MAX)) { + perror(progname); + had_errors++; + return NULL; + } + } + c = line; + do { + if (!fgets(c, line_size - (c - line), file)) + return NULL; + c = strrchr(c, '\0'); + while (c > line && (*(c-1) == '\n' || *(c-1) == '\r')) { + c--; + *c = '\0'; + eol = 1; + } + if (feof(file)) + break; + if (!eol) { + if (high_water_alloc((void **)&line, &line_size, + 2 * line_size)) { + perror(progname); + had_errors++; + return NULL; + } + c = strrchr(line, '\0'); + } + } while (!eol); + return line; } int main(int argc, char *argv[]) |