From 057ef182cd66fcc48fd5e69c8b8903c5c0cb7530 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 1 Feb 2015 09:58:02 +0000 Subject: [PATCH] Avoiding to print a wrong PID on the status bar. Patch by Kamil Dudka. Bug reported by Don Swaner. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5110 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/files.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7bd3095e..f6641605 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ the lock file -- a simple null_at() would not initialize the buffer. * src/files.c (do_lockfile): Make sure that 'lockprog' and 'lockuser' are terminated -- strncpy() does not guarantee that on its own. + * src/files.c (do_lockfile): Avoid printing a wrong PID on the status + bar due to treating serialized PID bytes as signed integers. This + addresses https://bugzilla.redhat.com/1186384 reported by Don Swaner. 2015-02-01 Benno Schulenberg * src/winio.c (do_credits): Add a general entry for all translators. diff --git a/src/files.c b/src/files.c index cbe46aee..43b8c13d 100644 --- a/src/files.c +++ b/src/files.c @@ -284,7 +284,7 @@ int do_lockfile(const char *filename) return -1; } strncpy(lockprog, &lockbuf[2], 10); - lockpid = lockbuf[25] * 256 + lockbuf[24]; + lockpid = (unsigned char)lockbuf[25] * 256 + (unsigned char)lockbuf[24]; strncpy(lockuser, &lockbuf[28], 16); #ifdef DEBUG fprintf(stderr, "lockpid = %d\n", lockpid); -- 2.39.5