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)
|
int patchLevel)
|
||||||
{
|
{
|
||||||
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
||||||
strncpy(pScreenPriv->clientDriverName, name,
|
strlcpy(pScreenPriv->clientDriverName, name,
|
||||||
DR_CLIENT_DRIVER_NAME_SIZE);
|
DR_CLIENT_DRIVER_NAME_SIZE);
|
||||||
strncpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
|
strlcpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
|
||||||
pScreenPriv->major = major;
|
pScreenPriv->major = major;
|
||||||
pScreenPriv->minor = minor;
|
pScreenPriv->minor = minor;
|
||||||
pScreenPriv->patchLevel = patchLevel;
|
pScreenPriv->patchLevel = patchLevel;
|
||||||
pScreenPriv->clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE-1] = 0;
|
|
||||||
pScreenPriv->busID[DR_BUSID_SIZE-1] = 0;
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,7 @@ static void dmxVDLDisplayEntry(const char *buf,
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
pt = strchr(buf, ' ');
|
pt = strchr(buf, ' ');
|
||||||
strncpy(name, buf, pt-buf);
|
strlcpy(name, buf, 1+pt-buf);
|
||||||
name[pt-buf] = '\0';
|
|
||||||
*len = strlen(name);
|
*len = strlen(name);
|
||||||
|
|
||||||
*x = strtol(pt, &end, 10);
|
*x = strtol(pt, &end, 10);
|
||||||
|
|
|
@ -153,7 +153,7 @@ static int getdimension(int token, const char *text, int leng)
|
||||||
char *tmp = dmxConfigAlloc(leng+1);
|
char *tmp = dmxConfigAlloc(leng+1);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
strncpy(tmp, text, leng);
|
strlcpy(tmp, text, leng+1);
|
||||||
x = strtol(tmp, &endptr, 10);
|
x = strtol(tmp, &endptr, 10);
|
||||||
while (*endptr && !isdigit(*endptr)) ++endptr;
|
while (*endptr && !isdigit(*endptr)) ++endptr;
|
||||||
y = strtol(endptr, NULL, 10);
|
y = strtol(endptr, NULL, 10);
|
||||||
|
|
|
@ -138,7 +138,7 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
|
||||||
for (ext = dpy->ext_procs;
|
for (ext = dpy->ext_procs;
|
||||||
ext && ext->codes.major_opcode != ev->request_code;
|
ext && ext->codes.major_opcode != ev->request_code;
|
||||||
ext = ext->next);
|
ext = ext->next);
|
||||||
if (ext) strncpy(buf, ext->name, sizeof(buf));
|
if (ext) strlcpy(buf, ext->name, sizeof(buf));
|
||||||
else buf[0] = '\0';
|
else buf[0] = '\0';
|
||||||
}
|
}
|
||||||
dmxLog(dmxWarning, " Major opcode: %d (%s)\n",
|
dmxLog(dmxWarning, " Major opcode: %d (%s)\n",
|
||||||
|
|
|
@ -195,8 +195,7 @@ xf86ValidateFontPath(char *path)
|
||||||
dirlen = p1 - path_elem;
|
dirlen = p1 - path_elem;
|
||||||
else
|
else
|
||||||
dirlen = strlen(path_elem);
|
dirlen = strlen(path_elem);
|
||||||
strncpy(dir_elem, path_elem, dirlen);
|
strlcpy(dir_elem, path_elem, dirlen + 1);
|
||||||
dir_elem[dirlen] = '\0';
|
|
||||||
flag = stat(dir_elem, &stat_buf);
|
flag = stat(dir_elem, &stat_buf);
|
||||||
if (flag == 0)
|
if (flag == 0)
|
||||||
if (!S_ISDIR(stat_buf.st_mode))
|
if (!S_ISDIR(stat_buf.st_mode))
|
||||||
|
|
|
@ -460,10 +460,9 @@ HostOS(void)
|
||||||
|
|
||||||
if (*host_os == '\0') {
|
if (*host_os == '\0') {
|
||||||
if (uname(&name) >= 0)
|
if (uname(&name) >= 0)
|
||||||
strcpy(host_os, name.sysname);
|
strlcpy(host_os, name.sysname, sizeof(host_os));
|
||||||
else {
|
else {
|
||||||
strncpy(host_os, "unknown", sizeof(host_os));
|
strlcpy(host_os, "unknown", sizeof(host_os));
|
||||||
host_os[sizeof(host_os)-1] = '\0';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return host_os;
|
return host_os;
|
||||||
|
|
|
@ -1235,8 +1235,7 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
|
||||||
#endif /* __GLIBC __ */
|
#endif /* __GLIBC __ */
|
||||||
xchomp(line);
|
xchomp(line);
|
||||||
if (isdigit(line[0])) {
|
if (isdigit(line[0])) {
|
||||||
strncpy(vendor_str, line, 4);
|
strlcpy(vendor_str, line, sizeof(vendor_str));
|
||||||
vendor_str[4] = '\0';
|
|
||||||
vendor = (int)strtol(vendor_str, NULL, 16);
|
vendor = (int)strtol(vendor_str, NULL, 16);
|
||||||
if ((strlen(&line[4])) == 0) {
|
if ((strlen(&line[4])) == 0) {
|
||||||
chip_str[0] = '\0';
|
chip_str[0] = '\0';
|
||||||
|
@ -1248,8 +1247,7 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
|
||||||
chip = -1;
|
chip = -1;
|
||||||
} else {
|
} else {
|
||||||
/* Ok, it's a real ID */
|
/* Ok, it's a real ID */
|
||||||
strncpy(chip_str, &line[4], 4);
|
strlcpy(chip_str, &line[4], sizeof(chip_str));
|
||||||
chip_str[4] = '\0';
|
|
||||||
chip = (int)strtol(chip_str, NULL, 16);
|
chip = (int)strtol(chip_str, NULL, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,8 +281,10 @@ again:
|
||||||
if (builtinConfig[builtinIndex] == NULL)
|
if (builtinConfig[builtinIndex] == NULL)
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
else {
|
else {
|
||||||
ret = strncpy(configBuf, builtinConfig[builtinIndex],
|
strlcpy(configBuf,
|
||||||
CONFIG_BUF_LEN);
|
builtinConfig[builtinIndex],
|
||||||
|
CONFIG_BUF_LEN);
|
||||||
|
ret = configBuf;
|
||||||
builtinIndex++;
|
builtinIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -813,8 +813,7 @@ Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(path, shared->shmPath, pathmax);
|
strlcpy(path, shared->shmPath, pathmax);
|
||||||
path[pathmax - 1] = '\0';
|
|
||||||
|
|
||||||
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
|
dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
|
||||||
|
|
||||||
|
|
|
@ -1756,8 +1756,7 @@ siHostnameAddrMatch(int family, pointer addr, int len,
|
||||||
if (siAddrLen >= sizeof(hostname))
|
if (siAddrLen >= sizeof(hostname))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
strncpy(hostname, siAddr, siAddrLen);
|
strlcpy(hostname, siAddr, siAddrLen + 1);
|
||||||
hostname[siAddrLen] = '\0';
|
|
||||||
|
|
||||||
if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
|
if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
|
||||||
for (a = addresses ; a != NULL ; a = a->ai_next) {
|
for (a = addresses ; a != NULL ; a = a->ai_next) {
|
||||||
|
@ -1786,8 +1785,7 @@ siHostnameAddrMatch(int family, pointer addr, int len,
|
||||||
if (siAddrLen >= sizeof(hostname))
|
if (siAddrLen >= sizeof(hostname))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
strncpy(hostname, siAddr, siAddrLen);
|
strlcpy(hostname, siAddr, siAddrLen + 1);
|
||||||
hostname[siAddrLen] = '\0';
|
|
||||||
|
|
||||||
if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
|
if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
|
||||||
#ifdef h_addr /* new 4.3bsd version of gethostent */
|
#ifdef h_addr /* new 4.3bsd version of gethostent */
|
||||||
|
|
|
@ -263,8 +263,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
|
||||||
if (xkbDebugFlags)
|
if (xkbDebugFlags)
|
||||||
DebugF("[xkb] xkb executes: %s\n",buf);
|
DebugF("[xkb] xkb executes: %s\n",buf);
|
||||||
if (nameRtrn) {
|
if (nameRtrn) {
|
||||||
strncpy(nameRtrn,keymap,nameRtrnLen);
|
strlcpy(nameRtrn,keymap,nameRtrnLen);
|
||||||
nameRtrn[nameRtrnLen-1]= '\0';
|
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -322,8 +321,7 @@ FILE * file;
|
||||||
}
|
}
|
||||||
else file= NULL;
|
else file= NULL;
|
||||||
if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
|
if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
|
||||||
strncpy(fileNameRtrn,buf,fileNameRtrnLen);
|
strlcpy(fileNameRtrn,buf,fileNameRtrnLen);
|
||||||
buf[fileNameRtrnLen-1]= '\0';
|
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,8 +250,7 @@ get_index(char *str, int *ndx)
|
||||||
*ndx = -1;
|
*ndx = -1;
|
||||||
return end + 1;
|
return end + 1;
|
||||||
}
|
}
|
||||||
strncpy(ndx_buf, str, end - str);
|
strlcpy(ndx_buf, str, 1 + end - str);
|
||||||
ndx_buf[end - str] = '\0';
|
|
||||||
*ndx = atoi(ndx_buf);
|
*ndx = atoi(ndx_buf);
|
||||||
return end + 1;
|
return end + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,7 @@ char *rtrn,*tmp;
|
||||||
if (len>BUFFER_SIZE)
|
if (len>BUFFER_SIZE)
|
||||||
len= BUFFER_SIZE-2;
|
len= BUFFER_SIZE-2;
|
||||||
rtrn= tbGetBuffer(len);
|
rtrn= tbGetBuffer(len);
|
||||||
strncpy(rtrn,atmstr,len);
|
strlcpy(rtrn,atmstr,len);
|
||||||
rtrn[len]= '\0';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rtrn= tbGetBuffer(1);
|
rtrn= tbGetBuffer(1);
|
||||||
|
|
Loading…
Reference in New Issue