The [-Wstringop-truncation] compiler flag triggers this. From the build output file we have:
gcc -o Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/pathsub.o -c -g -D_POSIX_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE -fPIC -DLINUX2_1 -Wall -Werror-implicit-function-declaration -Wno-switch -pipe -DLINUX -Dlinux -DHAVE_STRERROR -DXP_UNIX -DDEBUG -UNDEBUG -DDEBUG_emaldonado -D_REENTRANT -DUSE_UTIL_DIRECTLY -I../../../dist/Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/include -I../../../dist/public/coreconf -I../../../dist/private/coreconf pathsub.c pathsub.c: In function ‘reversepath’: pathsub.c:217:6: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation] strncpy(cp, "../", 3); ^~~~~~~~~~~~~~~~~~~~~ gcc -o Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/nsinstall -g -D_POSIX_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE -fPIC -DLINUX2_1 -Wall -Werror-implicit-function-declaration -Wno-switch -pipe -DLINUX -Dlinux -DHAVE_STRERROR -DXP_UNIX -DDEBUG -UNDEBUG -DDEBUG_emaldonado -D_REENTRANT -DUSE_UTIL_DIRECTLY -I../../../dist/Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/include -I../../../dist/public/coreconf -I../../../dist/private/coreconf Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/nsinstall.o Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/pathsub.o -lpthread -ldl -lc true -m 775 Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/nsinstall ../../../dist/Linux4.17_x86_64_glibc_PTH_64_DBG.OBJ/bin make[2]: Leaving directory '/home/emaldonado/COMPILER_WARNING/jss/coreconf/nsinstall'
Here is the relevant code from ./coreconf/nsinstall/pathsub.c
} else { cp -= 3; strncpy(cp, "../", 3); <--- the offending line xchdir(buf); }
Two simple ways to fix this:
Option 1:
} else { cp -= 3; const char *src = "../"; strncpy(cp, src, srtlen(src)); <--- the offedning line xchdir(buf); }
Option 2:
} else { cp -= 3; const char *src = "../"; mencpy(cp, "../", 3); <--- the offedning line xchdir(buf); }
I prefer the Option 2 as being simpler. Preferences anyone?
I meant to type memcpy(cp, "../", 3);
Simpler fix
<img alt="fixTruncationWarning.patch" src="/jss/issue/raw/files/1d0d8fd4a07ddf071ad66b1daaf5bc117531ebf1e612d4e519d8bb61fd52aab0-fixTruncationWarning.patch" />
@emaldonado the simpler fix is fine. Do you want to commit it and create the pull request on GitHub, or would you like one of the PKI devs to do it?
Metadata Update from @ftweedal: - Custom field component adjusted to None - Custom field feature adjusted to None - Custom field origin adjusted to None - Custom field proposedmilestone adjusted to None - Custom field proposedpriority adjusted to None - Custom field reviewer adjusted to None - Custom field type adjusted to None - Custom field version adjusted to None
(Updated comment to use Markdown formatting).
Upstream PR submitted by @emaldonado is jss pr#24.
This is fixed by jss pr#24. It is in master as 18cc00.
Metadata Update from @cipherboy: - Issue assigned to cipherboy
Metadata Update from @cipherboy: - Issue close_status updated to: fixed - Issue status updated to: Closed (was: Open)
Login to comment on this ticket.