diff options
author | Jim Meyering <meyering@redhat.com> | 2008-02-04 08:35:17 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-02-04 08:35:17 +0100 |
commit | cf282a908ec143e7ec8c8068fdc246b8bfaf8f33 (patch) | |
tree | 84b2b97d5abb7be7b54eae835995b519740ba980 /parted/ui.c | |
parent | 9f8b6836221804b7b8aa75456f9e38186253e1b4 (diff) | |
download | parted-cf282a908ec143e7ec8c8068fdc246b8bfaf8f33.tar.gz |
Don't write into line[-1] when line starts with a NUL byte.
* parted/ui.c (_readline): Check strlen first.
Diffstat (limited to 'parted/ui.c')
-rw-r--r-- | parted/ui.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/parted/ui.c b/parted/ui.c index 370c2be..d9ab107 100644 --- a/parted/ui.c +++ b/parted/ui.c @@ -572,7 +572,9 @@ _readline (const char* prompt, const StrList* possibilities) fputs (line, stdout); fflush (stdout); #endif - line [strlen (line) - 1] = 0; /* kill trailing CR */ + /* kill trailing NL */ + if (strlen (line)) + line [strlen (line) - 1] = 0; } else { free (line); line = NULL; |