Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 29510dd81e3a5e96151afdb0702863cbfd640766 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 22 Jun 2018 18:58:59 -0700 |
| 4 | Subject: [PATCH] check for size before using strncpy |
| 5 | |
| 6 | ensures that size is never execeding the string length |
| 7 | that execPath can hold |
| 8 | |
| 9 | Fixes |
| 10 | error: '__builtin___strncpy_chk' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] |
| 11 | |
| 12 | Upstream-Status: Pending |
| 13 | |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | src/imm/immnd/immnd_proc.c | 4 ++++ |
| 17 | 1 file changed, 4 insertions(+) |
| 18 | |
| 19 | diff --git a/src/imm/immnd/immnd_proc.c b/src/imm/immnd/immnd_proc.c |
| 20 | index 015932a..c8f115e 100644 |
| 21 | --- a/src/imm/immnd/immnd_proc.c |
| 22 | +++ b/src/imm/immnd/immnd_proc.c |
| 23 | @@ -1902,6 +1902,10 @@ static int immnd_forkPbe(IMMND_CB *cb) |
| 24 | LOG_ER("Pathname too long: %u max is 1023", newLen); |
| 25 | return -1; |
| 26 | } |
| 27 | + if (execDirLen > 1023 || execDirLen < 0) { |
| 28 | + LOG_ER("Execdir name too long: %u max is 1023", execDirLen); |
| 29 | + return -1; |
| 30 | + } |
| 31 | |
| 32 | strncpy(execPath, cb->mProgName, execDirLen); |
| 33 | execPath[execDirLen] = 0; |