Skip to content

Commit 946a1e4

Browse files
committed
Fix build warnings
- switch from strncpy to memcpy for -Wstringop-truncation
1 parent 1cbcf0f commit 946a1e4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

ext/phar/tar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /*
772772
}
773773
}
774774

775-
strncpy(header.magic, "ustar", sizeof("ustar")-1);
776-
strncpy(header.version, "00", sizeof("00")-1);
777-
strncpy(header.checksum, " ", sizeof(" ")-1);
775+
memcpy(header.magic, "ustar", sizeof("ustar")-1);
776+
memcpy(header.version, "00", sizeof("00")-1);
777+
memcpy(header.checksum, " ", sizeof(" ")-1);
778778
entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header));
779779

780780
if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) {

ext/phar/zip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
821821
memset(&local, 0, sizeof(local));
822822
memset(&central, 0, sizeof(central));
823823
memset(&perms, 0, sizeof(perms));
824-
strncpy(local.signature, "PK\3\4", 4);
825-
strncpy(central.signature, "PK\1\2", 4);
824+
memcpy(local.signature, "PK\3\4", 4);
825+
memcpy(central.signature, "PK\1\2", 4);
826826
PHAR_SET_16(central.extra_len, sizeof(perms));
827827
PHAR_SET_16(local.extra_len, sizeof(perms));
828828
perms.tag[0] = 'n';
@@ -1409,7 +1409,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
14091409
pass.free_fp = pass.free_ufp = 1;
14101410
memset(&eocd, 0, sizeof(eocd));
14111411

1412-
strncpy(eocd.signature, "PK\5\6", 4);
1412+
memcpy(eocd.signature, "PK\5\6", 4);
14131413
if (!phar->is_data && !phar->sig_flags) {
14141414
phar->sig_flags = PHAR_SIG_SHA1;
14151415
}

ext/standard/crypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ PHP_FUNCTION(crypt)
255255

256256
/* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */
257257
if (!*salt) {
258-
strncpy(salt, "$1$", 3);
258+
memcpy(salt, "$1$", 3);
259259
php_random_bytes_throw(&salt[3], 8);
260260
php_to64(&salt[3], 8);
261261
strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11);

0 commit comments

Comments
 (0)