Fix strncat build warnings when building with gcc.#31
Open
sprintersb wants to merge 1 commit intoumontreal-simul:masterfrom
Open
Fix strncat build warnings when building with gcc.#31sprintersb wants to merge 1 commit intoumontreal-simul:masterfrom
sprintersb wants to merge 1 commit intoumontreal-simul:masterfrom
Conversation
There are several places where suspect len arguments to strncat are specified, like for example in mylib/gdef.c::gdef_GetHostName(): strncat (machine, ", ", (size_t) 2); The semantics of strncat is that it writes at most 2 chars from ", " *plus* an additional terminating '\0' as needed. This is 3 chars, presumably what the authors intended. The obvious approach here would be to just use strcat for small static strings like in the sample, though the patch keeps the current coding style with strncat. * mylib/gdef.c (gdef_GetHostName): Use proper len specification in strncat calls, i.e. pass the size of the source rather than the length. * testu01/ubrent.c (ubrent_CreateXorgen64): Same. * testu01/ulec.c (ulec_CreateMRG31k3p): Same. * testu01/unif01.c (unif01_CreateLacGen, unif01_CreateBiasGen) (unif01_CreateDoubleGen2, unif01_CreateDoubleGen): Same. * testu01/svaria.c (svaria_SumLogs, svaria_WeightDistrib) (svaria_CollisionArgMax_00, svaria_SumCollector): When writing to chaine[], use the length of chaine[], i.e. LEN1 in strncat, instead of LEN2 which exceeds the length of chaine[].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are several places where suspect len arguments to strncat are specified, like for example in mylib/gdef.c::gdef_GetHostName():
The semantics of strncat is that it writes at most 2 chars from ", " plus an additional terminating '\0' as needed. This is 3 chars, presumably what the authors intended. The obvious approach here would be to just use strcat for small static strings like in the sample, though the patch keeps the current coding style with strncat.