Skip to content
Commit 6128e82e authored by Adhemerval Zanella Netto's avatar Adhemerval Zanella Netto Committed by Adhemerval Zanella
Browse files

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: default avatarCarlos O'Donell <carlos@redhat.com>
Tested-by: default avatarCarlos O'Donell <carlos@redhat.com>
parent cbf24edb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment