summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-05-02 18:03:41 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-05-02 18:03:41 -0700
commitb1a7317da58136686983c1a50e7f7d3a731dde02 (patch)
treed42407a3b5099d0b412b05e1f1104cc61c2de35a
parentd768e28a42b9187a2007361d6de263303f60bd4e (diff)
user2netname expects a MAXNETNAMELEN + 1 buffer, so give it one
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 *); | ^~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/app/xhost/-/merge_requests/7>
-rw-r--r--xhost.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/xhost.c b/xhost.c
index 1c855ee..22304bd 100644
--- a/xhost.c
+++ b/xhost.c
@@ -506,7 +506,7 @@ change_host(Display *dpy, char *name, Bool add)
(cp = strchr(name, '@'))) {
char *netname = name;
#ifdef SECURE_RPC
- static char username[MAXNETNAMELEN];
+ static char username[MAXNETNAMELEN + 1];
if (!cp[1]) {
struct passwd *pwd;