[parted-devel] FYI: don't write into line[-1] when line starts with a NUL byte.
Jim Meyering
jim at meyering.net
Mon Feb 4 07:41:17 UTC 2008
I've pushed this, too:
Don't write into line[-1] when line starts with a NUL byte.
* parted/ui.c (_readline): Check strlen first.
Signed-off-by: Jim Meyering <meyering at redhat.com>
---
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;
--
1.5.4.8.g2b39
More information about the parted-devel
mailing list