From ac23e47c3e75b98b718388228d2e0f73d2bfcc6d Mon Sep 17 00:00:00 2001 From: albert <> Date: Sat, 17 Jun 2006 05:01:17 +0000 Subject: [PATCH] pwdx: buffer overflow fixed -- thanks Ulf Harnhammar --- NEWS | 1 + pwdx.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 513e673e..c25a9bc5 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ top: terabytes -- thanks Tony Ernst ps: SCHED_BATCH is B ps: fix s format (signals) output with thread display watch: avoid integer overflow for the time delay +pwdx: buffer overflow fixed -- thanks Ulf Harnhammar procps-3.2.5 --> procps-3.2.6 diff --git a/pwdx.c b/pwdx.c index c1af1478..cb96a521 100644 --- a/pwdx.c +++ b/pwdx.c @@ -35,7 +35,7 @@ static void version(void) int main(int argc, char* argv[]) { - char buf[PATH_MAX]; + char buf[PATH_MAX+1]; regex_t re; int i; @@ -76,9 +76,9 @@ int main(int argc, char* argv[]) // or nnnn, so a simple check based on the first char is // possible if (argv[i][0] != '/') - sprintf(buf, "/proc/%s/cwd", argv[i]); + snprintf(buf, sizeof buf, "/proc/%s/cwd", argv[i]); else - sprintf(buf, "%s/cwd", argv[i]); + snprintf(buf, sizeof buf, "%s/cwd", argv[i]); // buf contains /proc/nnnn/cwd symlink name on entry, the // target of that symlink on return