Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from michel-slm/fix-stringop-truncation
Browse files Browse the repository at this point in the history
Suppress invalid stringop-truncation warnings
  • Loading branch information
warrenpw committed Jun 12, 2020
2 parents 7b42892 + 99675e6 commit 39d343b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ int main(int argc, char *argv[]) {
}

syslog(LOG_DEBUG, "Reading argument 1");
strncpy(state->crypt_mapper_name, argv[1], STRING_BUFFER_SIZE);
// suppress stringop-truncatation warning
// we already check for missing \0
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
(strncpy(state->crypt_mapper_name, argv[1], STRING_BUFFER_SIZE));
if (state->crypt_mapper_name[STRING_BUFFER_SIZE - 1] != 0) {
syslog(LOG_ERR, "Crypt device name overran buffer size of %d bytes.", STRING_BUFFER_SIZE);
exit(EX_SOFTWARE);
Expand Down Expand Up @@ -415,6 +419,7 @@ int main(int argc, char *argv[]) {
}
syslog(LOG_INFO, "Setting cache path to %s", state->cache_path);
}
# pragma GCC diagnostic pop

syslog(LOG_DEBUG, "Reading password from login module.");
if (fgets(state->password, PASSWORD_BUFFER_SIZE, stdin) == NULL) {
Expand Down

0 comments on commit 39d343b

Please sign in to comment.