Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Replace snprintf("%s") with strscpy

Replace snprintf("%s") with the faster and more direct strscpy().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20260201215247.677121-2-thorsten.blum@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Thorsten Blum and committed by
Alexei Starovoitov
d95d76aa 6b95cc56

+3 -2
+3 -2
kernel/bpf/btf.c
··· 25 25 #include <linux/perf_event.h> 26 26 #include <linux/bsearch.h> 27 27 #include <linux/kobject.h> 28 + #include <linux/string.h> 28 29 #include <linux/sysfs.h> 29 30 #include <linux/overflow.h> 30 31 ··· 6325 6324 btf->data_size = data_size; 6326 6325 btf->kernel_btf = true; 6327 6326 btf->named_start_id = 0; 6328 - snprintf(btf->name, sizeof(btf->name), "%s", name); 6327 + strscpy(btf->name, name); 6329 6328 6330 6329 err = btf_parse_hdr(env); 6331 6330 if (err) ··· 6444 6443 btf->start_str_off = base_btf->hdr.str_len; 6445 6444 btf->kernel_btf = true; 6446 6445 btf->named_start_id = 0; 6447 - snprintf(btf->name, sizeof(btf->name), "%s", module_name); 6446 + strscpy(btf->name, module_name); 6448 6447 6449 6448 btf->data = kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN); 6450 6449 if (!btf->data) {