Convert strncpy/strncat to strlcpy/strlcat
As long as we're carrying around a compatibility copy in os/strl*.c, might as well use them. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
parent
e189dbb3e5
commit
6e6d732bac
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user