From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11644 invoked from network); 17 Aug 2020 07:58:51 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 17 Aug 2020 07:58:51 -0000 Received: (qmail 6074 invoked by uid 550); 17 Aug 2020 07:58:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7890 invoked from network); 17 Aug 2020 04:12:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=/4wpGh1cDgFeIIMwy0oFJ4UH0aCXVLm13DofRHwjJu0=; b=P9BH6bwlB6Y59HgcikIoZCqG8G3cTX97DOlSx3zRz9/sHWMwRh75N3YHRw+CdRpdYI gDJCfuw2bJT8K1kzVdQUcE2let8gIIaRBmWgvvQlSXjJwjBJeTkEfP+KtnZdF7vJfiS3 ytfX43joOXsNdLuoK457NvrUwT1QF4E5EtfRPUdkD75qoMN0Cle0egZibKVvLJZR2LVi u4RwRjBw0ThNGcTyp5JD9xpC7ExkEgcYPijBu1uxVUiLm75s3+eaaOMzbBjARzNge28y 565s2aVSkHtvjFBCNzUJf4ZxQeb93LEZu7FvnDwsnFMHtypknC05n42Lpt5Ja+JJe8of 4o1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/4wpGh1cDgFeIIMwy0oFJ4UH0aCXVLm13DofRHwjJu0=; b=mRipnfmhzg9IHIM5U9VZO73SaqNClD7Rmlsq1su6C07l0zbZ5uhrbWchot9ufy5LPT ue/m/aCrM22ZmxakecLEEThkioWptmENsNeVeZTTa90PGpNV2H2nC3iIRWp72T+tX9rj Qf3mEog4ytU3sf3rxn47Lj+xnJ/e6O6NCCd2ezBWNpeltrxSb8AgPQB+UxPwSBb7RTEj oKAsAUS5X5iedwdEINGE/tcEL34OTDu9nUvAjhdzlblQPK/ZFmEUXeI03L/G8cmyNiJ2 L0XPex+VQ8/O5Rp2NYzpgB5KDCcl1HzfKe8ZpCUcSOJaNYPrAJnRgm3QWkyr/kE2qdab 51WQ== X-Gm-Message-State: AOAM530prOEv0JtlRfppAKh1QgJXbsj155EyBnuiSHkJTPHaRe/fQFFd wDkmrFPAB3AS1iiK7QpLYO8erZrHMckMK4wa3OW+54+knZk= X-Google-Smtp-Source: ABdhPJyKrEQHGtqK+asIDa44swXuQIkwMB5rD+HVbuHqbrAJbXiYY7b4KhDpen1kCEaTBLIOzPoy79hytzUPilnW8gg= X-Received: by 2002:a2e:a16f:: with SMTP id u15mr6940411ljl.5.1597637560870; Sun, 16 Aug 2020 21:12:40 -0700 (PDT) MIME-Version: 1.0 From: Waldek Kozaczuk Date: Mon, 17 Aug 2020 00:12:30 -0400 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="0000000000004bad2905ad0afba9" Subject: [musl] Both network/if_nametoindex.c and network/if_indextoname.c should use strlcpy instead of strncpy --0000000000004bad2905ad0afba9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, As I have been working on upgrading OSv ( https://github.com/cloudius-systems/osv) to latest version of musl, I have noticed that both network/if_nametoindex.c and network/if_indextoname.c use strncpy() to copy interface name to/from buffer. In both cases per https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html and https://linux.die.net/man/3/if_indextoname, it seems that ifname should be big enough to hold IF_NAMESIZE bytes which SHOULD include null terminating one. If that is the case both functions should use strlcpy instead of strncpy. Am I wrong? My regards, Waldemar Kozaczuk PS. Trying to compile if_nameindex() yields warning: CC musl/src/network/if_nameindex.c include/api/net/if.h: In function =E2=80=98if_nametoindex=E2=80=99: musl/src/network/if_nametoindex.c:14:2: error: =E2=80=98strncpy=E2=80=99 sp= ecified bound 16 equals destination size [-Werror=3Dstringop-truncation] 14 | strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); --0000000000004bad2905ad0afba9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

As I have been working on upgrading= OSv (https://github.co= m/cloudius-systems/osv) to latest version of musl, I have noticed that = both network/if_nametoindex.c and network/if_indextoname.c use strncpy() to= copy interface name to/from buffer. In both cases per=C2=A0https:= //pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html=C2=A0= and=C2=A0https://lin= ux.die.net/man/3/if_indextoname, it seems that=C2=A0=C2=A0ifname should= be big enough to hold=C2=A0IF_NAMESIZE bytes which SHOULD include null ter= minating one. If that is the case both functions should use strlcpy instead= of strncpy.

Am I wrong?

= My regards,
Waldemar Kozaczuk

PS. Trying= to compile if_nameindex() yields warning:

=C2=A0 = CC musl/src/network/if_nameindex.c
include/api/net/if.h: In function =E2= =80=98if_nametoindex=E2=80=99:
musl/src/network/if_nametoindex.c:14:2: e= rror: =E2=80=98strncpy=E2=80=99 specified bound 16 equals destination size = [-Werror=3Dstringop-truncation]
=C2=A0 =C2=A014 | =C2=A0strncpy(ifr.ifr_= name, name, sizeof ifr.ifr_name);
--0000000000004bad2905ad0afba9--