diff options
author | Jim Meyering <jim@meyering.net> | 2001-09-12 09:07:35 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-09-12 09:07:35 +0000 |
commit | 63a52bbb4c435e66c34d254e591dfc9aae195a47 (patch) | |
tree | 19d3eeaaaf556973bb7b93e4f7e92a505695e59c | |
parent | ea7b78f86878702ea9eee5ab5bbf2cc18a454098 (diff) | |
download | coreutils-63a52bbb4c435e66c34d254e591dfc9aae195a47.tar.xz |
The command `echo a|./fmt -2147483647' would cause fmt to segfault.
(fmt_paragraph): Test for sentinal directly, rather than
doing arithmetic with it's potentially large (INT_MAX) length.
-rw-r--r-- | src/fmt.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -816,6 +816,14 @@ fmt_paragraph (void) start->next_break = w; start->line_length = len; } + + /* This is a kludge to keep us from computing `len' as the + sum of the sentinel length and some non-zero number. + Since the sentinel w->length may be INT_MAX, adding + to that would give a negative result. */ + if (w == word_limit) + break; + len += (w - 1)->space + w->length; /* w > start >= word */ } while (len < max_width); |