Skip to content

Commit

Permalink
Fix gcc 8.1 error using strncpy as memcpy (warning converted as an er…
Browse files Browse the repository at this point in the history
…ror)

error: ‘strncpy’ output truncated before terminating nul copying N
bytes from a string of the same length [-Werror=stringop-truncation]
  • Loading branch information
dacap committed Aug 30, 2018
1 parent 9f8ba32 commit 44a14d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libarchive/archive_write_set_format_ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
}

memset(buff, ' ', 60);
strncpy(&buff[AR_fmag_offset], "`\n", 2);
memcpy(&buff[AR_fmag_offset], "`\n", 2);

if (strcmp(pathname, "/") == 0 ) {
/* Entry is archive symbol table in GNU format */
Expand All @@ -189,7 +189,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
}
if (strcmp(pathname, "__.SYMDEF") == 0) {
/* Entry is archive symbol table in BSD format */
strncpy(buff + AR_name_offset, "__.SYMDEF", 9);
memcpy(buff + AR_name_offset, "__.SYMDEF", 9);
goto stat;
}
if (strcmp(pathname, "//") == 0) {
Expand Down Expand Up @@ -289,7 +289,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
buff[AR_name_offset + strlen(filename)] = ' ';
}
else {
strncpy(buff + AR_name_offset, "#1/", 3);
memcpy(buff + AR_name_offset, "#1/", 3);
if (format_decimal(strlen(filename),
buff + AR_name_offset + 3,
AR_name_size - 3)) {
Expand Down

0 comments on commit 44a14d5

Please sign in to comment.