procps/0023-top-do-not-forget-the-fscanf-s-terminating-null-byte.patch

32 lines
1.0 KiB
Diff

From 14ef47af57f48d1e51ab91e80fd8f132fabb665a Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Tue, 3 Dec 2013 15:00:00 -0600
Subject: [PATCH] top: do not forget the fscanf %s terminating null byte
Reference(s):
http://www.freelists.org/post/procps/procpsng-339-defects-found
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git top/top.c top/top.c
index 4d1d912..bb15d01 100644
--- top/top.c
+++ top/top.c
@@ -3445,8 +3445,8 @@ static void configs_read (void) {
WIN_t *w = &Winstk[i];
p = fmtmk(N_fmt(RC_bad_entry_fmt), i+1, Rc_name);
- // note: "fieldscur=%__s" on next line should equal PFLAGSSIZ !
- if (2 != fscanf(fp, "%3s\tfieldscur=%80s\n"
+ // note: "fieldscur=%__s" on next line should equal (PFLAGSSIZ -1) !
+ if (2 != fscanf(fp, "%3s\tfieldscur=%79s\n"
, w->rc.winname, w->rc.fieldscur))
goto default_or_error;
#if PFLAGSSIZ > 80
--
1.7.9.2