{video,audio}: adjust unsafe strncpy usages

This commit is contained in:
sfan5 2023-01-09 21:22:50 +01:00
parent f4280e5238
commit 833bff8738
2 changed files with 3 additions and 3 deletions

View File

@ -116,7 +116,7 @@ static void device_descr_get(size_t dev_idx, char *buf, size_t buf_size)
snprintf(dev_path, sizeof(dev_path), PATH_DEV_MIXER"%zu", dev_idx);
int fd = open(dev_path, O_RDONLY);
if (ioctl(fd, SOUND_MIXER_INFO, &mi) == 0) {
strncpy(buf, mi.name, buf_size);
strncpy(buf, mi.name, buf_size - 1);
tmp = (buf_size - 1);
}
close(fd);

View File

@ -1597,8 +1597,8 @@ static void save_cached_program(struct ra *ra, struct ra_renderpass *pass,
.frag_bytecode_len = frag_bc.len,
.comp_bytecode_len = comp_bc.len,
};
strncpy(header.magic, cache_magic, sizeof(header.magic));
strncpy(header.compiler, spirv->name, sizeof(header.compiler));
memcpy(header.magic, cache_magic, sizeof(header.magic));
strncpy(header.compiler, spirv->name, sizeof(header.compiler) - 1);
struct bstr *prog = &pass->params.cached_program;
bstr_xappend(pass, prog, (bstr){ (char *) &header, sizeof(header) });