blob: 497bb07d8dc139d27360dcd36b840ab2963e0b0f [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 29510dd81e3a5e96151afdb0702863cbfd640766 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 22 Jun 2018 18:58:59 -0700
4Subject: [PATCH] check for size before using strncpy
5
6ensures that size is never execeding the string length
7that execPath can hold
8
9Fixes
10error: '__builtin___strncpy_chk' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
11
12Upstream-Status: Pending
13
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 src/imm/immnd/immnd_proc.c | 4 ++++
17 1 file changed, 4 insertions(+)
18
19diff --git a/src/imm/immnd/immnd_proc.c b/src/imm/immnd/immnd_proc.c
20index 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;