Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libnpfs: catch overflow in np_deserialize_p9dirent
Problem: compilation of diodls.c fails due to a potential string overflow when building a test deb. In function ‘snprintf’, inlined from ‘np_deserialize_p9dirent’ at ../libnpfs/np.c:1712:3, inlined from ‘npc_readdir_r’ at ../libnpclient/readdir.c:115:8, inlined from ‘lsdir’ at diodls.c:240:14: /usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: error: ‘__builtin___snprintf_chk’ specified bound 4097 exceeds destination size 256 [-Werror=stringop-overflow=] 71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^ lto1: all warnings being treated as errors Add an explicit check for the overflow and use memcpy() instead of snprintf("%.*s") here.
- Loading branch information