Replace all strcat with strlcat
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
f60d23fdb9
commit
134b8b538f
@ -4036,7 +4036,7 @@ static FAR char *mystrconcat(FAR const char *str, FAR const char *cat)
|
|||||||
if (answer)
|
if (answer)
|
||||||
{
|
{
|
||||||
strlcpy(answer, str, len);
|
strlcpy(answer, str, len);
|
||||||
strcat(answer, cat);
|
strlcat(answer, cat, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return answer;
|
return answer;
|
||||||
|
@ -165,8 +165,8 @@ int main(int argc, FAR char **argv)
|
|||||||
cmd[0] = '\0';
|
cmd[0] = '\0';
|
||||||
for (i = optind; i < argc; i++)
|
for (i = optind; i < argc; i++)
|
||||||
{
|
{
|
||||||
strcat(cmd, argv[i]);
|
strlcat(cmd, argv[i], sizeof(cmd));
|
||||||
strcat(cmd, " ");
|
strlcat(cmd, " ", sizeof(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
arg.command = cmd;
|
arg.command = cmd;
|
||||||
|
@ -236,7 +236,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
/* Got it; put together the full name. */
|
/* Got it; put together the full name. */
|
||||||
|
|
||||||
strcat(g_url, script_name + (star - g_file));
|
strlcat(g_url, script_name + (star - g_file),
|
||||||
|
sizeof(g_url));
|
||||||
|
|
||||||
/* XXX Whack the script_name, too? */
|
/* XXX Whack the script_name, too? */
|
||||||
|
|
||||||
|
@ -924,10 +924,10 @@ static int httpd_tilde_map1(httpd_conn *hc)
|
|||||||
|
|
||||||
if (prefix[0] != '\0')
|
if (prefix[0] != '\0')
|
||||||
{
|
{
|
||||||
strcat(hc->expnfilename, "/");
|
strlcat(hc->expnfilename, "/", hc->maxexpnfilename + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(hc->expnfilename, temp);
|
strlcat(hc->expnfilename, temp, hc->maxexpnfilename + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_THTTPD_TILDE_MAP1 */
|
#endif /* CONFIG_THTTPD_TILDE_MAP1 */
|
||||||
@ -975,8 +975,8 @@ static int httpd_tilde_map2(httpd_conn *hc)
|
|||||||
strlcpy(hc->altdir, pw->pw_dir, hc->maxaltdir + 1);
|
strlcpy(hc->altdir, pw->pw_dir, hc->maxaltdir + 1);
|
||||||
if (postfix[0] != '\0')
|
if (postfix[0] != '\0')
|
||||||
{
|
{
|
||||||
strcat(hc->altdir, "/");
|
strlcat(hc->altdir, "/", hc->maxaltdir + 1);
|
||||||
strcat(hc->altdir, postfix);
|
strlcat(hc->altdir, postfix, hc->maxaltdir + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
alt = expand_filename(hc->altdir, &rest, true);
|
alt = expand_filename(hc->altdir, &rest, true);
|
||||||
@ -1116,8 +1116,8 @@ static int vhost_map(httpd_conn *hc)
|
|||||||
httpd_realloc_str(&hc->expnfilename, &hc->maxexpnfilename,
|
httpd_realloc_str(&hc->expnfilename, &hc->maxexpnfilename,
|
||||||
strlen(hc->hostdir) + 1 + len);
|
strlen(hc->hostdir) + 1 + len);
|
||||||
strlcpy(hc->expnfilename, hc->hostdir, hc->maxexpnfilename + 1);
|
strlcpy(hc->expnfilename, hc->hostdir, hc->maxexpnfilename + 1);
|
||||||
strcat(hc->expnfilename, "/");
|
strlcat(hc->expnfilename, "/", hc->maxexpnfilename + 1);
|
||||||
strcat(hc->expnfilename, tempfilename);
|
strlcat(hc->expnfilename, tempfilename, hc->maxexpnfilename + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2875,14 +2875,14 @@ int httpd_parse_request(httpd_conn *hc)
|
|||||||
|
|
||||||
httpd_realloc_str(&hc->accept, &hc->maxaccept,
|
httpd_realloc_str(&hc->accept, &hc->maxaccept,
|
||||||
strlen(hc->accept) + 2 + strlen(cp));
|
strlen(hc->accept) + 2 + strlen(cp));
|
||||||
strcat(hc->accept, ", ");
|
strlcat(hc->accept, ", ", hc->maxaccepte + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
httpd_realloc_str(&hc->accept, &hc->maxaccept, strlen(cp));
|
httpd_realloc_str(&hc->accept, &hc->maxaccept, strlen(cp));
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(hc->accept, cp);
|
strlcat(hc->accept, cp, hc->maxaccepte + 1);
|
||||||
}
|
}
|
||||||
else if (strncasecmp(buf, "Accept-Encoding:", 16) == 0)
|
else if (strncasecmp(buf, "Accept-Encoding:", 16) == 0)
|
||||||
{
|
{
|
||||||
@ -2899,7 +2899,7 @@ int httpd_parse_request(httpd_conn *hc)
|
|||||||
|
|
||||||
httpd_realloc_str(&hc->accepte, &hc->maxaccepte,
|
httpd_realloc_str(&hc->accepte, &hc->maxaccepte,
|
||||||
strlen(hc->accepte) + 2 + strlen(cp));
|
strlen(hc->accepte) + 2 + strlen(cp));
|
||||||
strcat(hc->accepte, ", ");
|
strlcat(hc->accepte, ", ", hc->maxaccepte + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3296,7 +3296,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowp)
|
|||||||
indxlen = strlen(indexname);
|
indxlen = strlen(indexname);
|
||||||
if (indxlen == 0 || indexname[indxlen - 1] != '/')
|
if (indxlen == 0 || indexname[indxlen - 1] != '/')
|
||||||
{
|
{
|
||||||
strcat(indexname, "/");
|
strlcat(indexname, "/", maxindexname + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(indexname, "./") == 0)
|
if (strcmp(indexname, "./") == 0)
|
||||||
@ -3304,7 +3304,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowp)
|
|||||||
indexname[0] = '\0';
|
indexname[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(indexname, index_names[i]);
|
strlcat(indexname, index_names[i], maxindexname + 1);
|
||||||
if (stat(indexname, &hc->sb) >= 0)
|
if (stat(indexname, &hc->sb) >= 0)
|
||||||
{
|
{
|
||||||
goto got_one;
|
goto got_one;
|
||||||
|
@ -164,7 +164,6 @@ int xmlrpc_getstring(struct xmlrpc_s *xmlcall, char *arg)
|
|||||||
int xmlrpc_buildresponse(struct xmlrpc_s *xmlcall, char *args, ...)
|
int xmlrpc_buildresponse(struct xmlrpc_s *xmlcall, char *args, ...)
|
||||||
{
|
{
|
||||||
va_list argp;
|
va_list argp;
|
||||||
int ret = 0;
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int close = 0;
|
int close = 0;
|
||||||
int isstruct = 0;
|
int isstruct = 0;
|
||||||
@ -187,12 +186,13 @@ int xmlrpc_buildresponse(struct xmlrpc_s *xmlcall, char *args, ...)
|
|||||||
|
|
||||||
if (xmlcall->error)
|
if (xmlcall->error)
|
||||||
{
|
{
|
||||||
strcat(&xmlcall->response[strlen(xmlcall->response)], " <fault>\n");
|
strlcat(xmlcall->response, " <fault>\n",
|
||||||
|
sizeof(xmlcall->response));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcat(&xmlcall->response[strlen(xmlcall->response)],
|
strlcat(xmlcall->response, " <params><param>\n",
|
||||||
" <params><param>\n");
|
sizeof(xmlcall->response));
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(argp, args);
|
va_start(argp, args);
|
||||||
@ -268,26 +268,18 @@ int xmlrpc_buildresponse(struct xmlrpc_s *xmlcall, char *args, ...)
|
|||||||
|
|
||||||
if (xmlcall->error)
|
if (xmlcall->error)
|
||||||
{
|
{
|
||||||
strcat(&xmlcall->response[strlen(xmlcall->response)],
|
strlcat(xmlcall->response, " </fault>\r\n",
|
||||||
" </fault>\r\n");
|
sizeof(xmlcall->response));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcat(&xmlcall->response[strlen(xmlcall->response)],
|
strlcat(xmlcall->response, " </param></params>\r\n",
|
||||||
" </param></params>\r\n");
|
sizeof(xmlcall->response));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
strlcat(xmlcall->response, "</methodResponse>\r\n",
|
||||||
{
|
sizeof(xmlcall->response));
|
||||||
strcat(&xmlcall->response[strlen(xmlcall->response)],
|
|
||||||
"</methodResponse>\r\n");
|
|
||||||
|
|
||||||
xmlrpc_insertlength(xmlcall);
|
xmlrpc_insertlength(xmlcall);
|
||||||
}
|
return 0;
|
||||||
else
|
|
||||||
{
|
|
||||||
xmlcall->response[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1106,7 @@ static FAR char *nsh_strcat(FAR struct nsh_vtbl_s *vtbl, FAR char *s1,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
argument[s1size] = '\0'; /* (In case s1 was NULL) */
|
argument[s1size] = '\0'; /* (In case s1 was NULL) */
|
||||||
strcat(argument, s2);
|
strlcat(argument, s2, allocsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return argument;
|
return argument;
|
||||||
|
@ -333,14 +333,14 @@ static int compose_name(FAR const char *fname, FAR char *oname, int namelen)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(oname, fname, namelen);
|
strlcpy(oname, fname, namelen);
|
||||||
p = strchr(oname, '.');
|
p = strchr(oname, '.');
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
*p = '_'; /* _ for dot */
|
*p = '_'; /* _ for dot */
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat (oname, ".lzf");
|
strlcat(oname, ".lzf", namelen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -372,13 +372,12 @@ static int compose_name(FAR const char *fname, FAR char *oname, int namelen)
|
|||||||
static int run_file(FAR const char *fname)
|
static int run_file(FAR const char *fname)
|
||||||
{
|
{
|
||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
char oname[PATH_MAX + 1];
|
char oname[PATH_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
int fd2;
|
int fd2;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(oname, 0, sizeof(oname));
|
if (compose_name(fname, oname, sizeof(oname)))
|
||||||
if (compose_name(fname, oname, PATH_MAX + 1))
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
int rc;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(command, 0, sizeof(command));
|
command[0] = '\0';
|
||||||
|
|
||||||
CPU_ZERO(&cpuset);
|
CPU_ZERO(&cpuset);
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse command line options */
|
||||||
@ -156,8 +155,8 @@ int main(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
for (i = 0; i < argc - 2; i++)
|
for (i = 0; i < argc - 2; i++)
|
||||||
{
|
{
|
||||||
strcat(command, argv[i + 2]);
|
strlcat(command, argv[i + 2], sizeof(command));
|
||||||
strcat(command, " ");
|
strlcat(command, " ", sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_setaffinity(gettid(), sizeof(cpu_set_t), &cpuset);
|
sched_setaffinity(gettid(), sizeof(cpu_set_t), &cpuset);
|
||||||
|
@ -1091,23 +1091,23 @@ static int tcurses_vt100_setattributes(FAR struct termcurses_s *dev,
|
|||||||
|
|
||||||
if (attrib & TCURS_ATTRIB_BLINK)
|
if (attrib & TCURS_ATTRIB_BLINK)
|
||||||
{
|
{
|
||||||
strcat(str, g_setblink);
|
strlcat(str, g_setblink, sizeof(str));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcat(str, g_setnoblink);
|
strlcat(str, g_setnoblink, sizeof(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrib & TCURS_ATTRIB_UNDERLINE)
|
if (attrib & TCURS_ATTRIB_UNDERLINE)
|
||||||
{
|
{
|
||||||
strcat(str, g_setunderline);
|
strlcat(str, g_setunderline, sizeof(str));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcat(str, g_setnounderline);
|
strlcat(str, g_setnounderline, sizeof(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(str, "m");
|
strlcat(str, "m", sizeof(str));
|
||||||
|
|
||||||
ret = write(fd, str, strlen(str));
|
ret = write(fd, str, strlen(str));
|
||||||
|
|
||||||
|
@ -261,11 +261,11 @@ static int trace_cmd_cmd(int index, int argc, FAR char **argv, int notectlfd)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(command, 0, sizeof(command));
|
command[0] = '\0';
|
||||||
while (index < argc)
|
while (index < argc)
|
||||||
{
|
{
|
||||||
strcat(command, argv[index]);
|
strlcat(command, argv[index], sizeof(command));
|
||||||
strcat(command, " ");
|
strlcat(command, " ", sizeof(command));
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
strcat(path, FILE_NAME);
|
strlcat(path, FILE_NAME, sizeof(path));
|
||||||
|
|
||||||
printf("open(%s)\n", path);
|
printf("open(%s)\n", path);
|
||||||
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
||||||
|
@ -1021,7 +1021,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
if (ctx->mountdir[strlen(ctx->mountdir)-1] != '/')
|
if (ctx->mountdir[strlen(ctx->mountdir)-1] != '/')
|
||||||
{
|
{
|
||||||
strcat(ctx->mountdir, "/");
|
strlcat(ctx->mountdir, "/", sizeof(ctx->mountdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->fileimage = calloc(ctx->max_file, 1);
|
ctx->fileimage = calloc(ctx->max_file, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user