sunrpc: Suppress GCC -Os warning on user2netname
commit6128e82ebe973163d2dd614d31753c88c0c4d645
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Wed, 21 Sep 2022 13:51:07 +0000 (21 10:51 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 5 Oct 2022 21:04:13 +0000 (5 18:04 -0300)
tree50893182729984be2b346aa99253026d0580a0a3
parentcbf24edbb3123e3154ad2366912e0c1270ad3546
sunrpc: Suppress GCC -Os warning on user2netname

GCC with -Os warns that sprint might overflow:

  netname.c: In function ‘user2netname’:
  netname.c:51:28: error: ‘%s’ directive writing up to 255 bytes into a
  region of size between 239 and 249 [-Werror=format-overflow=]
     51 |   sprintf (netname, "%s.%d@%s", OPSYS, uid, dfltdom);
        |                            ^~               ~~~~~~~
  netname.c:51:3: note: ‘sprintf’ output between 8 and 273 bytes into a
  destination of size 256
     51 |   sprintf (netname, "%s.%d@%s", OPSYS, uid, dfltdom);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

However the code does test prior the sprintf call that dfltdom plus
the required extra space for OPSYS, uid, and extra character will not
overflow and return 0 instead.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
sunrpc/netname.c