aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/xkb
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2019-06-21 11:01:59 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-06-22 11:30:54 +0200
commit813acdd2df24a8e3f44152d90a26f1beef11b38c (patch)
tree8ae129ae995cca0418778b58d5e36d7e954e82ba /nx-X11/programs/Xserver/xkb
parent054e906f6059366150bb7426973542203c8a0e4c (diff)
downloadnx-libs-813acdd2df24a8e3f44152d90a26f1beef11b38c.tar.gz
nx-libs-813acdd2df24a8e3f44152d90a26f1beef11b38c.tar.bz2
nx-libs-813acdd2df24a8e3f44152d90a26f1beef11b38c.zip
xkb: Silence some compiler warnings
commit 83913de25d35709b3ab7b0ab124b73924145d2dd Author: Adam Jackson <ajax@redhat.com> Date: Thu Apr 5 12:59:11 2018 -0400 xkb: Silence some compiler warnings Of the form: ../xkb/XKBGAlloc.c: In function ‘SrvXkbAddGeomKeyAlias’: ../xkb/XKBGAlloc.c:591:13: warning: ‘strncpy’ specified bound 4 equals destination size [-Wstringop-truncation] strncpy(alias->real, realStr, XkbKeyNameLength); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is intentional; the code that reads from these fields never reads more than 4 bytes anyway. Rephrase things in terms of memcpy so that's clear. Obviously this is awful but in XKB awful is par. Signed-off-by: Adam Jackson <ajax@redhat.com> Acked-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'nx-X11/programs/Xserver/xkb')
-rw-r--r--nx-X11/programs/Xserver/xkb/XKBGAlloc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/nx-X11/programs/Xserver/xkb/XKBGAlloc.c b/nx-X11/programs/Xserver/xkb/XKBGAlloc.c
index ac757232e..bfbd0c325 100644
--- a/nx-X11/programs/Xserver/xkb/XKBGAlloc.c
+++ b/nx-X11/programs/Xserver/xkb/XKBGAlloc.c
@@ -702,7 +702,8 @@ register XkbKeyAliasPtr alias;
for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
bzero(alias->real,XkbKeyNameLength);
- strncpy(alias->real,realStr,XkbKeyNameLength);
+ memcpy(alias->real, realStr,
+ min(XkbKeyNameLength, strlen(realStr)));
return alias;
}
}
@@ -712,8 +713,8 @@ register XkbKeyAliasPtr alias;
}
alias= &geom->key_aliases[geom->num_key_aliases];
bzero(alias,sizeof(XkbKeyAliasRec));
- strncpy(alias->alias,aliasStr,XkbKeyNameLength);
- strncpy(alias->real,realStr,XkbKeyNameLength);
+ memcpy(alias->alias, aliasStr, min(XkbKeyNameLength, strlen(aliasStr)));
+ memcpy(alias->real, realStr, min(XkbKeyNameLength, strlen(realStr)));
geom->num_key_aliases++;
return alias;
}
@@ -930,8 +931,8 @@ Bool found;
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success))
return NULL;
key= &row->keys[row->num_keys];
- strncpy(key->under.name,under,XkbKeyNameLength);
- strncpy(key->over.name,over,XkbKeyNameLength);
+ memcpy(key->under.name, under, min(XkbKeyNameLength, strlen(under)));
+ memcpy(key->over.name, over, min(XkbKeyNameLength, strlen(over)));
row->num_keys++;
return key;
}