Skip to content

Commit

Permalink
Fix gcc warning
Browse files Browse the repository at this point in the history
Addressing:
/home/jcerny/openscap/src/XCCDF_POLICY/xccdf_policy_remediate.c: In
function ‘_comment_multiline_text’:
/home/jcerny/openscap/src/XCCDF_POLICY/xccdf_policy_remediate.c:845:5:
warning: ‘strncpy’ output truncated before terminating nul copying 3
bytes from a string of the same length [-Wstringop-truncation]
     strncpy(buffer + result_len, filler, filler_len);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jcerny/openscap/src/XCCDF_POLICY/xccdf_policy_remediate.c:852:4:
warning: ‘strncpy’ output truncated before terminating nul copying as
many bytes from a string as its length [-Wstringop-truncation]
    strncpy(buffer + result_len, token, token_len);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jcerny/openscap/src/XCCDF_POLICY/xccdf_policy_remediate.c:837:16:
note: length computed here
    token_len = strlen(token);
                ^~~~~~~~~~~~~
  • Loading branch information
jan-cerny committed Feb 19, 2019
1 parent d9fc6b6 commit 5f52a19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/XCCDF_POLICY/xccdf_policy_remediate.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,14 @@ static char *_comment_multiline_text(char *text)
buffer_size += filler_len;
buffer = realloc(buffer, buffer_size);
}
strncpy(buffer + result_len, filler, filler_len);
strncpy(buffer + result_len, filler, filler_len + 1);
result_len += filler_len;
}
if (buffer_size < result_len + token_len + 1) {
buffer_size += token_len;
buffer = realloc(buffer, buffer_size);
}
strncpy(buffer + result_len, token, token_len);
strncpy(buffer + result_len, token, token_len + 1);
result_len += token_len;
first = false;
}
Expand Down

0 comments on commit 5f52a19

Please sign in to comment.