Skip to content

Commit ba7bdec

Browse files
azeemshaikh38davem330
authored andcommitted
net: Replace strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 84bef5b commit ba7bdec

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

include/trace/events/fib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ TRACE_EVENT(fib_table_lookup,
6565
}
6666

6767
dev = nhc ? nhc->nhc_dev : NULL;
68-
strlcpy(__entry->name, dev ? dev->name : "-", IFNAMSIZ);
68+
strscpy(__entry->name, dev ? dev->name : "-", IFNAMSIZ);
6969

7070
if (nhc) {
7171
if (nhc->nhc_gw_family == AF_INET) {

include/trace/events/fib6.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ TRACE_EVENT(fib6_table_lookup,
6363
}
6464

6565
if (res->nh && res->nh->fib_nh_dev) {
66-
strlcpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ);
66+
strscpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ);
6767
} else {
6868
strcpy(__entry->name, "-");
6969
}

0 commit comments

Comments
 (0)