summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xext/xvmc.c6
-rw-r--r--hw/dmx/config/dmxcompat.c3
-rw-r--r--hw/dmx/config/scanner.l2
-rw-r--r--hw/dmx/dmxinit.c2
-rw-r--r--hw/xfree86/common/xf86Config.c3
-rw-r--r--hw/xfree86/common/xf86Xinput.c5
-rw-r--r--hw/xfree86/common/xf86pciBus.c6
-rw-r--r--hw/xfree86/parser/scan.c6
-rw-r--r--hw/xquartz/xpr/dri.c3
-rw-r--r--os/access.c6
-rw-r--r--xkb/ddxLoad.c6
-rw-r--r--xkb/maprules.c3
-rw-r--r--xkb/xkbtext.c3
13 files changed, 21 insertions, 33 deletions
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index bc78b55ae..47b9f476e 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -777,14 +777,12 @@ xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
int patchLevel)
{
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
- strncpy(pScreenPriv->clientDriverName, name,
+ strlcpy(pScreenPriv->clientDriverName, name,
DR_CLIENT_DRIVER_NAME_SIZE);
- strncpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
+ strlcpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
pScreenPriv->major = major;
pScreenPriv->minor = minor;
pScreenPriv->patchLevel = patchLevel;
- pScreenPriv->clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE-1] = 0;
- pScreenPriv->busID[DR_BUSID_SIZE-1] = 0;
return Success;
}
diff --git a/hw/dmx/config/dmxcompat.c b/hw/dmx/config/dmxcompat.c
index b4190ffcc..98c52eb0e 100644
--- a/hw/dmx/config/dmxcompat.c
+++ b/hw/dmx/config/dmxcompat.c
@@ -94,8 +94,7 @@ static void dmxVDLDisplayEntry(const char *buf,
char *end;
pt = strchr(buf, ' ');
- strncpy(name, buf, pt-buf);
- name[pt-buf] = '\0';
+ strlcpy(name, buf, 1+pt-buf);
*len = strlen(name);
*x = strtol(pt, &end, 10);
diff --git a/hw/dmx/config/scanner.l b/hw/dmx/config/scanner.l
index f5bb73b41..e527d6df5 100644
--- a/hw/dmx/config/scanner.l
+++ b/hw/dmx/config/scanner.l
@@ -153,7 +153,7 @@ static int getdimension(int token, const char *text, int leng)
char *tmp = dmxConfigAlloc(leng+1);
int x, y;
- strncpy(tmp, text, leng);
+ strlcpy(tmp, text, leng+1);
x = strtol(tmp, &endptr, 10);
while (*endptr && !isdigit(*endptr)) ++endptr;
y = strtol(endptr, NULL, 10);
diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index 165476c5f..b950c50a4 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -138,7 +138,7 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
for (ext = dpy->ext_procs;
ext && ext->codes.major_opcode != ev->request_code;
ext = ext->next);
- if (ext) strncpy(buf, ext->name, sizeof(buf));
+ if (ext) strlcpy(buf, ext->name, sizeof(buf));
else buf[0] = '\0';
}
dmxLog(dmxWarning, " Major opcode: %d (%s)\n",
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index cb4be4210..cc7997364 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -195,8 +195,7 @@ xf86ValidateFontPath(char *path)
dirlen = p1 - path_elem;
else
dirlen = strlen(path_elem);
- strncpy(dir_elem, path_elem, dirlen);
- dir_elem[dirlen] = '\0';
+ strlcpy(dir_elem, path_elem, dirlen + 1);
flag = stat(dir_elem, &stat_buf);
if (flag == 0)
if (!S_ISDIR(stat_buf.st_mode))
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7feb48c1e..b9753f01d 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -460,10 +460,9 @@ HostOS(void)
if (*host_os == '\0') {
if (uname(&name) >= 0)
- strcpy(host_os, name.sysname);
+ strlcpy(host_os, name.sysname, sizeof(host_os));
else {
- strncpy(host_os, "unknown", sizeof(host_os));
- host_os[sizeof(host_os)-1] = '\0';
+ strlcpy(host_os, "unknown", sizeof(host_os));
}
}
return host_os;
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 87dc02512..1fee93792 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -1235,8 +1235,7 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
#endif /* __GLIBC __ */
xchomp(line);
if (isdigit(line[0])) {
- strncpy(vendor_str, line, 4);
- vendor_str[4] = '\0';
+ strlcpy(vendor_str, line, sizeof(vendor_str));
vendor = (int)strtol(vendor_str, NULL, 16);
if ((strlen(&line[4])) == 0) {
chip_str[0] = '\0';
@@ -1248,8 +1247,7 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
chip = -1;
} else {
/* Ok, it's a real ID */
- strncpy(chip_str, &line[4], 4);
- chip_str[4] = '\0';
+ strlcpy(chip_str, &line[4], sizeof(chip_str));
chip = (int)strtol(chip_str, NULL, 16);
}
}
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 99b325717..847078986 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -281,8 +281,10 @@ again:
if (builtinConfig[builtinIndex] == NULL)
ret = NULL;
else {
- ret = strncpy(configBuf, builtinConfig[builtinIndex],
- CONFIG_BUF_LEN);
+ strlcpy(configBuf,
+ builtinConfig[builtinIndex],
+ CONFIG_BUF_LEN);
+ ret = configBuf;
builtinIndex++;
}
}
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 8bae6b009..a58f2c76d 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -813,8 +813,7 @@ Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
return FALSE;
}
- strncpy(path, shared->shmPath, pathmax);
- path[pathmax - 1] = '\0';
+ strlcpy(path, shared->shmPath, pathmax);
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
diff --git a/os/access.c b/os/access.c
index f31626d96..159894007 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1756,8 +1756,7 @@ siHostnameAddrMatch(int family, pointer addr, int len,
if (siAddrLen >= sizeof(hostname))
return FALSE;
- strncpy(hostname, siAddr, siAddrLen);
- hostname[siAddrLen] = '\0';
+ strlcpy(hostname, siAddr, siAddrLen + 1);
if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
for (a = addresses ; a != NULL ; a = a->ai_next) {
@@ -1786,8 +1785,7 @@ siHostnameAddrMatch(int family, pointer addr, int len,
if (siAddrLen >= sizeof(hostname))
return FALSE;
- strncpy(hostname, siAddr, siAddrLen);
- hostname[siAddrLen] = '\0';
+ strlcpy(hostname, siAddr, siAddrLen + 1);
if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
#ifdef h_addr /* new 4.3bsd version of gethostent */
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 219d39c9a..196142318 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -263,8 +263,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
if (xkbDebugFlags)
DebugF("[xkb] xkb executes: %s\n",buf);
if (nameRtrn) {
- strncpy(nameRtrn,keymap,nameRtrnLen);
- nameRtrn[nameRtrnLen-1]= '\0';
+ strlcpy(nameRtrn,keymap,nameRtrnLen);
}
free(buf);
#ifdef WIN32
@@ -322,8 +321,7 @@ FILE * file;
}
else file= NULL;
if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
- strncpy(fileNameRtrn,buf,fileNameRtrnLen);
- buf[fileNameRtrnLen-1]= '\0';
+ strlcpy(fileNameRtrn,buf,fileNameRtrnLen);
}
return file;
}
diff --git a/xkb/maprules.c b/xkb/maprules.c
index f94089982..a14fbbb2a 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -250,8 +250,7 @@ get_index(char *str, int *ndx)
*ndx = -1;
return end + 1;
}
- strncpy(ndx_buf, str, end - str);
- ndx_buf[end - str] = '\0';
+ strlcpy(ndx_buf, str, 1 + end - str);
*ndx = atoi(ndx_buf);
return end + 1;
}
diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
index 9f49d59ff..1ba10a194 100644
--- a/xkb/xkbtext.c
+++ b/xkb/xkbtext.c
@@ -81,8 +81,7 @@ char *rtrn,*tmp;
if (len>BUFFER_SIZE)
len= BUFFER_SIZE-2;
rtrn= tbGetBuffer(len);
- strncpy(rtrn,atmstr,len);
- rtrn[len]= '\0';
+ strlcpy(rtrn,atmstr,len);
}
else {
rtrn= tbGetBuffer(1);