Skip to content

user2netname expects a MAXNETNAMELEN + 1 buffer, so give it one

Alan Coopersmith requested to merge alanc/xhost:rpc into master

Found by gcc 13.2 on Solaris 11.4:

xhost.c: In function ‘change_host’:
xhost.c:522:18: warning: ‘user2netname’ accessing 256 bytes in a region of size 255 [-Wstringop-overflow=]
  522 |             if (!user2netname(username, pwd->pw_uid, domainname)) {
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xhost.c:522:18: note: referencing argument 1 of type ‘char[256]’
In file included from /usr/include/rpc/rpc.h:35,
                 from xhost.c:98:
/usr/include/rpc/auth.h:316:12: note: in a call to function ‘user2netname’
  316 | extern int user2netname(char [MAXNETNAMELEN + 1], const uid_t, const char *);
      |           ^~~~~~~~~~~~
Edited by Alan Coopersmith

Merge request reports