mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
{video,audio}: adjust unsafe strncpy usages
This commit is contained in:
parent
f4280e5238
commit
833bff8738
@ -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);
|
snprintf(dev_path, sizeof(dev_path), PATH_DEV_MIXER"%zu", dev_idx);
|
||||||
int fd = open(dev_path, O_RDONLY);
|
int fd = open(dev_path, O_RDONLY);
|
||||||
if (ioctl(fd, SOUND_MIXER_INFO, &mi) == 0) {
|
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);
|
tmp = (buf_size - 1);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -1597,8 +1597,8 @@ static void save_cached_program(struct ra *ra, struct ra_renderpass *pass,
|
|||||||
.frag_bytecode_len = frag_bc.len,
|
.frag_bytecode_len = frag_bc.len,
|
||||||
.comp_bytecode_len = comp_bc.len,
|
.comp_bytecode_len = comp_bc.len,
|
||||||
};
|
};
|
||||||
strncpy(header.magic, cache_magic, sizeof(header.magic));
|
memcpy(header.magic, cache_magic, sizeof(header.magic));
|
||||||
strncpy(header.compiler, spirv->name, sizeof(header.compiler));
|
strncpy(header.compiler, spirv->name, sizeof(header.compiler) - 1);
|
||||||
|
|
||||||
struct bstr *prog = &pass->params.cached_program;
|
struct bstr *prog = &pass->params.cached_program;
|
||||||
bstr_xappend(pass, prog, (bstr){ (char *) &header, sizeof(header) });
|
bstr_xappend(pass, prog, (bstr){ (char *) &header, sizeof(header) });
|
||||||
|
Loading…
Reference in New Issue
Block a user