Replace all strncpy with strlcpy
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
7c37421266
commit
73701cd7cd
@ -256,9 +256,7 @@ static int chat_parse_args(FAR struct chat_app *priv)
|
||||
|
||||
/* set the TTY device node */
|
||||
|
||||
strncpy(priv->tty,
|
||||
(FAR char *)priv->argv[i] + 2,
|
||||
CHAT_TTYNAME_SIZE - 1);
|
||||
strlcpy(priv->tty, priv->argv[i] + 2, CHAT_TTYNAME_SIZE);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
@ -266,13 +264,11 @@ static int chat_parse_args(FAR struct chat_app *priv)
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
ret = chat_script_read(priv,
|
||||
(FAR char *)priv->argv[i] + 2);
|
||||
ret = chat_script_read(priv, priv->argv[i] + 2);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
numarg = strtol((FAR char *)priv->argv[i] + 2,
|
||||
NULL, 10);
|
||||
numarg = strtol(priv->argv[i] + 2, NULL, 10);
|
||||
if (errno < 0)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
@ -283,8 +279,7 @@ static int chat_parse_args(FAR struct chat_app *priv)
|
||||
break;
|
||||
|
||||
case 't':
|
||||
numarg = strtol((FAR char *)priv->argv[i] + 2,
|
||||
NULL, 10);
|
||||
numarg = strtol(priv->argv[i] + 2, NULL, 10);
|
||||
|
||||
if (errno < 0 || numarg < 0)
|
||||
{
|
||||
@ -336,7 +331,7 @@ int main(int argc, FAR char **argv)
|
||||
priv.ctl.timeout = CONFIG_EXAMPLES_CHAT_TIMEOUT_SECONDS;
|
||||
priv.script = NULL;
|
||||
priv.script_dynalloc = false;
|
||||
strncpy(priv.tty, CONFIG_EXAMPLES_CHAT_TTY_DEVNODE, CHAT_TTYNAME_SIZE - 1);
|
||||
strlcpy(priv.tty, CONFIG_EXAMPLES_CHAT_TTY_DEVNODE, CHAT_TTYNAME_SIZE);
|
||||
|
||||
_info("parsing the arguments\n");
|
||||
ret = chat_parse_args((FAR struct chat_app *)&priv);
|
||||
|
@ -107,7 +107,7 @@ static int flowc_cmdline(int argc, char **argv)
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
strncpy(g_tty_devname, argv[1], MAX_DEVNAME);
|
||||
strlcpy(g_tty_devname, argv[1], MAX_DEVNAME);
|
||||
}
|
||||
else if (argc != 1)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ static int flowc_cmdline(int argc, char **argv)
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
strncpy(g_tty_devname, argv[1], MAX_DEVNAME);
|
||||
strlcpy(g_tty_devname, argv[1], MAX_DEVNAME);
|
||||
}
|
||||
else if (argc != 1)
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ static int ipfwd_tun_configure(FAR struct ipfwd_tun_s *tun)
|
||||
return -errcode;
|
||||
}
|
||||
|
||||
strncpy(tun->it_devname, ifr.ifr_name, MAX_DEVNAME);
|
||||
strlcpy(tun->it_devname, ifr.ifr_name, MAX_DEVNAME);
|
||||
printf("Created TUN device: %s\n", tun->it_devname);
|
||||
return 0;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ int main(int argc, FAR char *argv[])
|
||||
for (i = w + msg_len; i > 0; i--)
|
||||
{
|
||||
memset(visbuf, ' ', w);
|
||||
strncpy(scrollbuf + i, message, msg_len);
|
||||
strlcpy(scrollbuf + i, message, msg_len);
|
||||
mvwaddnstr(win, height / 2, 1, visbuf, w);
|
||||
wrefresh(win);
|
||||
|
||||
|
@ -274,8 +274,8 @@ static int rpsock_stream_client(int argc, char *argv[])
|
||||
/* Connect the socket to the server */
|
||||
|
||||
myaddr.rp_family = AF_RPMSG;
|
||||
strncpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
strncpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
strlcpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
strlcpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
|
||||
printf("client: Connecting to %s,%s...\n", myaddr.rp_cpu, myaddr.rp_name);
|
||||
ret = connect(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr));
|
||||
@ -468,8 +468,8 @@ static int rpsock_dgram_client(int argc, char *argv[])
|
||||
/* Connect the socket to the server */
|
||||
|
||||
myaddr.rp_family = AF_RPMSG;
|
||||
strncpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
strncpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
strlcpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
strlcpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
|
||||
printf("client: Connecting to %s,%s...\n", myaddr.rp_cpu, myaddr.rp_name);
|
||||
ret = connect(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr));
|
||||
|
@ -187,10 +187,10 @@ static int rpsock_stream_server(int argc, char *argv[])
|
||||
/* Bind the socket to a local address */
|
||||
|
||||
myaddr.rp_family = AF_RPMSG;
|
||||
strncpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
strlcpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
if (argc == 5)
|
||||
{
|
||||
strncpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
strlcpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -300,10 +300,10 @@ static int rpsock_dgram_server(int argc, char *argv[])
|
||||
/* Bind the socket to a local address */
|
||||
|
||||
myaddr.rp_family = AF_RPMSG;
|
||||
strncpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
strlcpy(myaddr.rp_name, argv[3], RPMSG_SOCKET_NAME_SIZE);
|
||||
if (argc == 5)
|
||||
{
|
||||
strncpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
strlcpy(myaddr.rp_cpu, argv[4], RPMSG_SOCKET_CPU_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -88,15 +88,14 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
/* Set up the server address */
|
||||
|
||||
addrlen = strlen(CONFIG_EXAMPLES_UDGRAM_ADDR);
|
||||
if (addrlen > UNIX_PATH_MAX - 1)
|
||||
addrlen = strlen(CONFIG_EXAMPLES_UDGRAM_ADDR) + 1;
|
||||
if (addrlen > UNIX_PATH_MAX)
|
||||
{
|
||||
addrlen = UNIX_PATH_MAX - 1;
|
||||
addrlen = UNIX_PATH_MAX;
|
||||
}
|
||||
|
||||
server.sun_family = AF_LOCAL;
|
||||
strncpy(server.sun_path, CONFIG_EXAMPLES_UDGRAM_ADDR, addrlen);
|
||||
server.sun_path[addrlen] = '\0';
|
||||
strlcpy(server.sun_path, CONFIG_EXAMPLES_UDGRAM_ADDR, addrlen);
|
||||
|
||||
addrlen += sizeof(sa_family_t) + 1;
|
||||
|
||||
|
@ -89,15 +89,14 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
/* Bind the socket to a local address */
|
||||
|
||||
addrlen = strlen(CONFIG_EXAMPLES_UDGRAM_ADDR);
|
||||
if (addrlen > UNIX_PATH_MAX - 1)
|
||||
addrlen = strlen(CONFIG_EXAMPLES_UDGRAM_ADDR) + 1;
|
||||
if (addrlen > UNIX_PATH_MAX)
|
||||
{
|
||||
addrlen = UNIX_PATH_MAX - 1;
|
||||
addrlen = UNIX_PATH_MAX;
|
||||
}
|
||||
|
||||
server.sun_family = AF_LOCAL;
|
||||
strncpy(server.sun_path, CONFIG_EXAMPLES_UDGRAM_ADDR, addrlen);
|
||||
server.sun_path[addrlen] = '\0';
|
||||
strlcpy(server.sun_path, CONFIG_EXAMPLES_UDGRAM_ADDR, addrlen);
|
||||
|
||||
addrlen += sizeof(sa_family_t) + 1;
|
||||
|
||||
|
@ -522,7 +522,7 @@ static int ufstest_rename(FAR void *volinfo, FAR const char *oldrelpath,
|
||||
file = ufstest_findbyname(oldrelpath);
|
||||
if (file != NULL)
|
||||
{
|
||||
strncpy(file->entry.d_name, newrelpath, NAME_MAX + 1);
|
||||
strlcpy(file->entry.d_name, newrelpath, NAME_MAX);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -78,14 +78,14 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
/* Connect the socket to the server */
|
||||
|
||||
addrlen = strlen(CONFIG_EXAMPLES_USTREAM_ADDR);
|
||||
if (addrlen > UNIX_PATH_MAX - 1)
|
||||
addrlen = strlen(CONFIG_EXAMPLES_USTREAM_ADDR) + 1;
|
||||
if (addrlen > UNIX_PATH_MAX)
|
||||
{
|
||||
addrlen = UNIX_PATH_MAX - 1;
|
||||
addrlen = UNIX_PATH_MAX;
|
||||
}
|
||||
|
||||
myaddr.sun_family = AF_LOCAL;
|
||||
strncpy(myaddr.sun_path, CONFIG_EXAMPLES_USTREAM_ADDR, addrlen);
|
||||
strlcpy(myaddr.sun_path, CONFIG_EXAMPLES_USTREAM_ADDR, addrlen);
|
||||
myaddr.sun_path[addrlen] = '\0';
|
||||
|
||||
printf("client: Connecting to %s...\n", CONFIG_EXAMPLES_USTREAM_ADDR);
|
||||
|
@ -78,14 +78,14 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
/* Bind the socket to a local address */
|
||||
|
||||
addrlen = strlen(CONFIG_EXAMPLES_USTREAM_ADDR);
|
||||
if (addrlen > UNIX_PATH_MAX - 1)
|
||||
addrlen = strlen(CONFIG_EXAMPLES_USTREAM_ADDR) + 1;
|
||||
if (addrlen > UNIX_PATH_MAX)
|
||||
{
|
||||
addrlen = UNIX_PATH_MAX - 1;
|
||||
addrlen = UNIX_PATH_MAX;
|
||||
}
|
||||
|
||||
myaddr.sun_family = AF_LOCAL;
|
||||
strncpy(myaddr.sun_path, CONFIG_EXAMPLES_USTREAM_ADDR, addrlen);
|
||||
strlcpy(myaddr.sun_path, CONFIG_EXAMPLES_USTREAM_ADDR, addrlen);
|
||||
myaddr.sun_path[addrlen] = '\0';
|
||||
|
||||
addrlen += sizeof(sa_family_t) + 1;
|
||||
|
@ -153,8 +153,7 @@ int passwd_find(FAR const char *username, FAR struct passwd_s *passwd)
|
||||
}
|
||||
|
||||
passwd->offset = offset;
|
||||
strncpy(passwd->encrypted, encrypted, MAX_ENCRYPTED);
|
||||
passwd->encrypted[MAX_ENCRYPTED] = '\0';
|
||||
strlcpy(passwd->encrypted, encrypted, MAX_ENCRYPTED);
|
||||
|
||||
ret = OK;
|
||||
break;
|
||||
|
@ -85,8 +85,8 @@ static void replace_extension(FAR const char *filename, FAR const char *newext,
|
||||
len = size - strlen(newext);
|
||||
}
|
||||
|
||||
strncpy(dest, filename, size);
|
||||
strncpy(dest + len, newext, size - len);
|
||||
strlcpy(dest, filename, size);
|
||||
strlcpy(dest + len, newext, size - len);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -2913,8 +2913,7 @@ static FAR char *midstring(void)
|
||||
return str;
|
||||
}
|
||||
|
||||
strncpy(answer, temp, len);
|
||||
answer[len] = 0;
|
||||
strlcpy(answer, temp, len + 1);
|
||||
free(str);
|
||||
return answer;
|
||||
}
|
||||
|
@ -364,8 +364,8 @@ static int nxscope_put_vector(FAR uint8_t *buff, uint8_t type, FAR void *val,
|
||||
|
||||
DEBUGASSERT(val);
|
||||
|
||||
strncpy((FAR char *)buff, (FAR const char *)val, d);
|
||||
j += strnlen((FAR char *)buff, d);
|
||||
strlcpy((FAR char *)buff, (FAR const char *)val, d);
|
||||
j += strlen((FAR char *)buff);
|
||||
memset(&buff[j], '\0', d - j);
|
||||
j = d;
|
||||
|
||||
|
@ -1724,7 +1724,7 @@ static FAR void *dhcp6c_precise_open(FAR const char *ifname,
|
||||
|
||||
/* Detect interface */
|
||||
|
||||
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if (ioctl(pdhcp6c->sockfd, SIOCGIFINDEX, &ifr))
|
||||
{
|
||||
close(pdhcp6c->urandom_fd);
|
||||
|
@ -144,8 +144,8 @@ static inline void discover_initresponse(void)
|
||||
g_state.response[0] = DISCOVER_PROTO_ID;
|
||||
g_state.response[1] = DISCOVER_RESPONSE;
|
||||
|
||||
strncpy((char *)&g_state.response[2], g_state.info.description,
|
||||
DISCOVER_RESPONSE_SIZE - 3);
|
||||
strlcpy((char *)&g_state.response[2], g_state.info.description,
|
||||
DISCOVER_RESPONSE_SIZE - 2);
|
||||
|
||||
for (i = 0; i < DISCOVER_RESPONSE_SIZE - 1; i++)
|
||||
{
|
||||
|
@ -1059,8 +1059,7 @@ static int lesp_parse_cwjap_ans_line(char *ptr, lesp_ap_t *ap)
|
||||
case 1:
|
||||
ptr++; /* Remove first '"' */
|
||||
*(ptr_next - 1) = '\0';
|
||||
strncpy(ap->ssid, ptr, LESP_SSID_SIZE);
|
||||
ap->ssid[LESP_SSID_SIZE] = '\0';
|
||||
strlcpy(ap->ssid, ptr, LESP_SSID_SIZE + 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@ -1185,8 +1184,7 @@ static int lesp_parse_cwlap_ans_line(char *ptr, lesp_ap_t *ap)
|
||||
case 2:
|
||||
ptr++; /* Remove first '"' */
|
||||
*(ptr_next - 1) = '\0';
|
||||
strncpy(ap->ssid, ptr, LESP_SSID_SIZE);
|
||||
ap->ssid[LESP_SSID_SIZE] = '\0';
|
||||
strlcpy(ap->ssid, ptr, LESP_SSID_SIZE + 1);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
@ -238,7 +238,7 @@ int fptc_getreply(struct ftpc_session_s *session)
|
||||
{
|
||||
/* Multi-line response */
|
||||
|
||||
strncpy(tmp, session->reply, 3);
|
||||
strlcpy(tmp, session->reply, sizeof(tmp));
|
||||
do
|
||||
{
|
||||
if (ftpc_gets(session) == -1)
|
||||
|
@ -78,9 +78,9 @@ void curl4nx_easy_reset(FAR struct curl4nx_s *handle)
|
||||
/* Setup default options */
|
||||
|
||||
handle->port = 80;
|
||||
strncpy(handle->useragent, CONFIG_LIBCURL4NX_USERAGENT,
|
||||
strlcpy(handle->useragent, CONFIG_LIBCURL4NX_USERAGENT,
|
||||
sizeof(handle->useragent));
|
||||
strncpy(handle->method, "GET", sizeof(handle->method));
|
||||
strlcpy(handle->method, "GET", sizeof(handle->method));
|
||||
handle->version = CURL4NX_HTTP_VERSION_1_1;
|
||||
handle->writefunc = curl4nx_default_writefunc;
|
||||
|
||||
|
@ -216,7 +216,7 @@ static int get_filename(char *vfilename, char *filename,
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(fn, filename, size);
|
||||
strlcpy(fn, filename, fnsize);
|
||||
strlcpy(&fn[size], val, fnsize - size);
|
||||
}
|
||||
else if (strcmp(tag, "file") == 0)
|
||||
@ -419,8 +419,7 @@ static void do_config(FILE *instream, char *vfilename, char *filename,
|
||||
|
||||
if (strcmp(tag, "g_timeformat") == 0)
|
||||
{
|
||||
strncpy(g_timeformat, val, TIMEFMT_SIZE - 1);
|
||||
g_timeformat[TIMEFMT_SIZE - 1] = '\0';
|
||||
strlcpy(g_timeformat, val, TIMEFMT_SIZE);
|
||||
}
|
||||
else if (strcmp(tag, "g_sizefmt") == 0)
|
||||
{
|
||||
|
@ -92,8 +92,6 @@
|
||||
# define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
#define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
|
||||
extern CODE char *crypt(const char *key, const char *setting);
|
||||
|
||||
/* Conditional macro to allow two alternate forms for use in the built-in
|
||||
@ -1240,7 +1238,7 @@ static char *expand_filename(char *path, char **restp, bool tildemapped)
|
||||
/* Special case for absolute paths. */
|
||||
|
||||
httpd_realloc_str(&checked, &maxchecked, checkedlen + 1);
|
||||
strncpy(&checked[checkedlen], r, 1);
|
||||
checked[checkedlen] = '/';
|
||||
checkedlen += 1;
|
||||
}
|
||||
else if (strncmp(r, "..", MAX(i, 2)) == 0)
|
||||
@ -1660,15 +1658,15 @@ static void ls_child(int argc, char **argv)
|
||||
if (maxnames == 0)
|
||||
{
|
||||
maxnames = 100;
|
||||
names = NEW(char, maxnames * (PATH_MAX + 1));
|
||||
names = NEW(char, maxnames * PATH_MAX);
|
||||
nameptrs = NEW(char *, maxnames);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldmax = maxnames;
|
||||
maxnames *= 2;
|
||||
names = RENEW(names, char, oldmax * (PATH_MAX + 1),
|
||||
maxnames * (PATH_MAX + 1));
|
||||
names = RENEW(names, char, oldmax * PATH_MAX,
|
||||
maxnames * PATH_MAX);
|
||||
nameptrs = RENEW(nameptrs, char *, oldmax, maxnames);
|
||||
}
|
||||
|
||||
@ -1680,13 +1678,11 @@ static void ls_child(int argc, char **argv)
|
||||
|
||||
for (i = 0; i < maxnames; ++i)
|
||||
{
|
||||
nameptrs[i] = &names[i * (PATH_MAX + 1)];
|
||||
nameptrs[i] = &names[i * PATH_MAX];
|
||||
}
|
||||
}
|
||||
|
||||
namlen = NAMLEN(de);
|
||||
strncpy(nameptrs[nnames], de->d_name, namlen);
|
||||
nameptrs[nnames][namlen] = '\0';
|
||||
strlcpy(nameptrs[nnames], de->d_name, PATH_MAX);
|
||||
++nnames;
|
||||
}
|
||||
|
||||
|
@ -457,10 +457,9 @@ static inline int wget_parsestatus(struct webclient_context *ctx,
|
||||
ninfo("Got HTTP status %lu\n", http_status);
|
||||
if (ctx->http_reason != NULL)
|
||||
{
|
||||
strncpy(ctx->http_reason,
|
||||
strlcpy(ctx->http_reason,
|
||||
ep + 1,
|
||||
ctx->http_reason_len - 1);
|
||||
ctx->http_reason[ctx->http_reason_len - 1] = 0;
|
||||
ctx->http_reason_len);
|
||||
}
|
||||
|
||||
/* Check for 2xx (Successful) */
|
||||
@ -693,7 +692,7 @@ static inline int wget_parseheaders(struct webclient_context *ctx,
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
strncpy(ws->mimetype, ws->line + strlen(g_httpcontenttype),
|
||||
strlcpy(ws->mimetype, ws->line + strlen(g_httpcontenttype),
|
||||
sizeof(ws->mimetype));
|
||||
found = true;
|
||||
}
|
||||
@ -1564,7 +1563,7 @@ int webclient_perform(FAR struct webclient_context *ctx)
|
||||
{
|
||||
memset(&server_un, 0, sizeof(server_un));
|
||||
server_un.sun_family = AF_LOCAL;
|
||||
strncpy(server_un.sun_path, ctx->unix_socket_path,
|
||||
strlcpy(server_un.sun_path, ctx->unix_socket_path,
|
||||
sizeof(server_un.sun_path));
|
||||
#if !defined(__NuttX__) && !defined(__linux__)
|
||||
server_un.sun_len = SUN_LEN(&server_un);
|
||||
|
@ -126,7 +126,7 @@ static void nsh_token(FAR struct console_stdio_s *pstate,
|
||||
|
||||
/* Copied the token into the buffer */
|
||||
|
||||
strncpy(buffer, start, buflen);
|
||||
strlcpy(buffer, start, buflen);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -134,7 +134,7 @@ static void nsh_telnettoken(FAR struct console_stdio_s *pstate,
|
||||
|
||||
/* Copied the token into the buffer */
|
||||
|
||||
strncpy(buffer, start, buflen);
|
||||
strlcpy(buffer, start, buflen);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -248,7 +248,7 @@ static void cfgdatacmd_set(int argc, char *argv[])
|
||||
|
||||
/* Copy the name to the cfg struct */
|
||||
|
||||
strncpy(cfg.name, argv[2], CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
strlcpy(cfg.name, argv[2], CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
|
||||
#else
|
||||
|
||||
@ -377,7 +377,7 @@ static void cfgdatacmd_unset(int argc, char *argv[])
|
||||
#ifdef CONFIG_MTD_CONFIG_NAMED
|
||||
/* Copy the name to the cfg struct */
|
||||
|
||||
strncpy(cfg.name, argv[2], CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
strlcpy(cfg.name, argv[2], CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
|
||||
#else
|
||||
int x;
|
||||
@ -443,7 +443,7 @@ static void cfgdatacmd_print(int argc, char *argv[])
|
||||
|
||||
/* Copy the name to the cfg struct */
|
||||
|
||||
strncpy(cfg.name, argv[2], CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
strlcpy(cfg.name, argv[2], CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
|
||||
#else
|
||||
|
||||
|
@ -2167,8 +2167,8 @@ FAR struct nxplayer_s *nxplayer_create(void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
|
||||
strncpy(pplayer->mediadir, CONFIG_NXPLAYER_DEFAULT_MEDIADIR,
|
||||
sizeof(pplayer->mediadir));
|
||||
strlcpy(pplayer->mediadir, CONFIG_NXPLAYER_DEFAULT_MEDIADIR,
|
||||
sizeof(pplayer->mediadir));
|
||||
#endif
|
||||
|
||||
pthread_mutex_init(&pplayer->mutex, NULL);
|
||||
|
@ -335,8 +335,7 @@ static void tab_completion(FAR struct rl_common_s *vtbl, char *buf,
|
||||
}
|
||||
|
||||
#endif
|
||||
strncpy(buf, tmp_name, buflen - 1);
|
||||
|
||||
strlcpy(buf, tmp_name, buflen);
|
||||
name_len = strlen(tmp_name);
|
||||
|
||||
/* Output the original prompt */
|
||||
|
@ -313,8 +313,6 @@ static int ubloxmodem_status(FAR struct ubloxmodem_cxt *cxt)
|
||||
FAR struct ubxmdm_regval register_values[UBLOXMODEM_MAX_REGISTERS];
|
||||
char regname[4]; /* Null-terminated string buffer */
|
||||
|
||||
regname[3] = '\0'; /* Set the null string terminator */
|
||||
|
||||
/* Set the maximum value, to be updated by driver */
|
||||
|
||||
status.register_values_size = UBLOXMODEM_MAX_REGISTERS;
|
||||
@ -332,7 +330,7 @@ static int ubloxmodem_status(FAR struct ubloxmodem_cxt *cxt)
|
||||
i < status.register_values_size && i < UBLOXMODEM_MAX_REGISTERS;
|
||||
i++)
|
||||
{
|
||||
strncpy(regname, status.register_values[i].name, 3);
|
||||
strlcpy(regname, status.register_values[i].name, sizeof(regname));
|
||||
printf("%s=%d ",
|
||||
regname,
|
||||
(int) status.register_values[i].val);
|
||||
|
@ -4432,13 +4432,7 @@ static void vi_parsecolon(FAR struct vi_s *vi)
|
||||
* as unmodified.
|
||||
*/
|
||||
|
||||
strncpy(vi->filename, filename, MAX_FILENAME - 1);
|
||||
|
||||
/* Make sure that the (possibly truncated) file name is NUL
|
||||
* terminated
|
||||
*/
|
||||
|
||||
vi->filename[MAX_FILENAME - 1] = '\0';
|
||||
strlcpy(vi->filename, filename, MAX_FILENAME);
|
||||
vi->modified = false;
|
||||
}
|
||||
else
|
||||
@ -4462,13 +4456,7 @@ static void vi_parsecolon(FAR struct vi_s *vi)
|
||||
|
||||
if (filename)
|
||||
{
|
||||
strncpy(vi->filename, filename, MAX_FILENAME - 1);
|
||||
|
||||
/* Make sure that the (possibly truncated) file name is NUL
|
||||
* terminated
|
||||
*/
|
||||
|
||||
vi->filename[MAX_FILENAME - 1] = '\0';
|
||||
strlcpy(vi->filename, filename, MAX_FILENAME);
|
||||
}
|
||||
|
||||
/* If it is not a new file and if there are no changes to the text
|
||||
@ -4783,13 +4771,7 @@ static void vi_parsefind(FAR struct vi_s *vi, bool revfind)
|
||||
{
|
||||
/* Copy the new search string from the scratch to the find buffer */
|
||||
|
||||
strncpy(vi->findstr, vi->scratch, MAX_STRING - 1);
|
||||
|
||||
/* Make sure that the (possibly truncated) search string is NUL
|
||||
* terminated
|
||||
*/
|
||||
|
||||
vi->findstr[MAX_STRING - 1] = '\0';
|
||||
strlcpy(vi->findstr, vi->scratch, MAX_STRING);
|
||||
}
|
||||
|
||||
/* Then attempt to find the string */
|
||||
@ -5643,7 +5625,7 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
if (argv[optind][0] == '/')
|
||||
{
|
||||
strncpy(vi->filename, argv[optind], MAX_STRING - 1);
|
||||
strlcpy(vi->filename, argv[optind], MAX_STRING);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -145,8 +145,7 @@ static void parse_commandline(FAR struct pwm_state_s *pwm_state, int argc,
|
||||
switch (ch)
|
||||
{
|
||||
case 'p':
|
||||
strncpy(pwm_state->devpath, optarg, sizeof(pwm_state->devpath));
|
||||
pwm_state->devpath[sizeof(pwm_state->devpath) - 1] = '\0';
|
||||
strlcpy(pwm_state->devpath, optarg, sizeof(pwm_state->devpath));
|
||||
break;
|
||||
case 'd':
|
||||
OPTARG_TO_VALUE(converted, uint8_t, 10);
|
||||
|
@ -88,8 +88,7 @@ static void parse_commandline(FAR struct rtc_state_s *rtc_state, int argc,
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
strncpy(rtc_state->devpath, optarg, sizeof(rtc_state->devpath));
|
||||
rtc_state->devpath[sizeof(rtc_state->devpath) - 1] = '\0';
|
||||
strlcpy(rtc_state->devpath, optarg, sizeof(rtc_state->devpath));
|
||||
break;
|
||||
|
||||
case '?':
|
||||
|
@ -142,9 +142,8 @@ static void parse_commandline(FAR struct timer_state_s *timer_state,
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
strncpy(timer_state->devpath, optarg,
|
||||
strlcpy(timer_state->devpath, optarg,
|
||||
sizeof(timer_state->devpath));
|
||||
timer_state->devpath[sizeof(timer_state->devpath) - 1] = '\0';
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
|
@ -246,14 +246,12 @@ static void parse_commandline(FAR struct wdg_state_s *wdg_state, int argc,
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
strncpy(wdg_state->devpath, optarg, sizeof(wdg_state->devpath));
|
||||
wdg_state->devpath[sizeof(wdg_state->devpath) - 1] = '\0';
|
||||
strlcpy(wdg_state->devpath, optarg, sizeof(wdg_state->devpath));
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
strncpy(wdg_state->infopath, optarg,
|
||||
strlcpy(wdg_state->infopath, optarg,
|
||||
sizeof(wdg_state->infopath));
|
||||
wdg_state->infopath[sizeof(wdg_state->infopath) - 1] = '\0';
|
||||
break;
|
||||
|
||||
case 't':
|
||||
|
Loading…
Reference in New Issue
Block a user