fix a potential buffer overflow in clientid.c:rc_map2id()

This fixes the following compile-time warning when building with
-D_FORTIFY_SOURCE=2:

In file included from /usr/include/string.h:638:0,
                 from ./includes.h:26,
                 from clientid.c:12:
In function 'strncat',
    inlined from 'rc_map2id' at clientid.c:113:9:
/usr/include/i386-linux-gnu/bits/string3.h:150:3: warning: call to
__builtin___strncat_chk might overflow destination buffer [enabled by default]
   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
   ^

Origin: vendor, https://build.opensuse.org/source/network/ppp/ppp-2.4.4-strncatfix.patch?rev=7a0fdeff0b29437dd7f4581c95c7255a
Forwarded: no
Reviewed-by: Chris Boot <bootc@debian.org>
Last-Update: 2014-01-12


Gbp-Pq: Name ppp-2.4.4-strncatfix.patch
This commit is contained in:
Ubuntu Developers 2022-05-14 02:43:52 +08:00 committed by openKylinBot
parent b97740c995
commit 3862c478e2
1 changed files with 1 additions and 1 deletions

View File

@ -110,7 +110,7 @@ UINT4 rc_map2id(char *name)
if (*name != '/')
strcpy(ttyname, "/dev/");
strncat(ttyname, name, sizeof(ttyname));
strncat(ttyname, name, sizeof(ttyname)-strlen(ttyname)-1);
for(p = map2id_list; p; p = p->next)
if (!strcmp(ttyname, p->name)) return p->id;