* null terminating of IFLA_INFO_KIND/IFLA_IFNAME
@ 2021-02-17 16:06 Муравьев Александр
2021-02-17 17:08 ` David Ahern
0 siblings, 1 reply; 2+ messages in thread
From: Муравьев Александр @ 2021-02-17 16:06 UTC (permalink / raw)
To: netdev
Hi
A noob question that I haven't found an answer.
Just wanted to clarify a piece of iproute2 code.
ip/iplink.c:
> 1058 addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
> 1059 strlen(type));
also ip/iplink.c:
> 1115 addattr_l(&req.n, sizeof(req),
> 1116 !check_ifname(name) ? IFLA_IFNAME : IFLA_ALT_IFNAME,
> 1117 name, strlen(name) + 1);
My question is why we skip terminating null character for IFLA_INFO_KIND
(the first case) and don't skip it for IFLA_IFNAME (the second case)? I
mean "strlen(type)" and "strlen(name) + 1".
--
Best regards,
Alexander Muravev
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: null terminating of IFLA_INFO_KIND/IFLA_IFNAME
2021-02-17 16:06 null terminating of IFLA_INFO_KIND/IFLA_IFNAME Муравьев Александр
@ 2021-02-17 17:08 ` David Ahern
0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2021-02-17 17:08 UTC (permalink / raw)
To: Муравьев
Александр,
netdev
On 2/17/21 9:06 AM, Муравьев Александр wrote:
> Hi
>
> A noob question that I haven't found an answer.
>
> Just wanted to clarify a piece of iproute2 code.
>
> ip/iplink.c:
>
>> 1058 addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
>> 1059 strlen(type));
>
> also ip/iplink.c:
>
>> 1115 addattr_l(&req.n, sizeof(req),
>> 1116 !check_ifname(name) ? IFLA_IFNAME : IFLA_ALT_IFNAME,
>> 1117 name, strlen(name) + 1);
> My question is why we skip terminating null character for IFLA_INFO_KIND
> (the first case) and don't skip it for IFLA_IFNAME (the second case)? I
> mean "strlen(type)" and "strlen(name) + 1".
>
I think it is just different coders at different points in time. Kernel
side both use nla_strscpy which handles the string terminator (or
missing terminator).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-17 17:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 16:06 null terminating of IFLA_INFO_KIND/IFLA_IFNAME Муравьев Александр
2021-02-17 17:08 ` David Ahern
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.