mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-18 17:32:09 +08:00
change strcpy to strlcpy
Change-Id: I8b9429a3c225a82842fce136bdb14b8b135066d3 Signed-off-by: lilei19 <lilei19@xiaomi.com>
This commit is contained in:
@@ -566,9 +566,9 @@ static void cfgdatacmd_show_all_config_items(void)
|
||||
printf(fmtstr, "Name", "Len");
|
||||
sprintf(fmtstr, "%%-%ds%%-6d", CONFIG_MTD_CONFIG_NAME_LEN);
|
||||
#else
|
||||
strcpy(fmtstr, "%-6s%-6s%-6sData\n");
|
||||
strlcpy(fmtstr, "%-6s%-6s%-6sData\n", sizeof(fmtstr));
|
||||
printf(fmtstr, "ID", "Inst", "Len");
|
||||
strcpy(fmtstr, "%-6d%-6d%-6d");
|
||||
strlcpy(fmtstr, "%-6d%-6d%-6d", sizeof(fmtstr));
|
||||
#endif
|
||||
|
||||
/* Get the first config item */
|
||||
@@ -620,7 +620,7 @@ static void cfgdatacmd_show_all_config_items(void)
|
||||
#ifdef CONFIG_MTD_CONFIG_NAMED
|
||||
sprintf(fmtstr2, "\n%ds", CONFIG_MTD_CONFIG_NAME_LEN + 6);
|
||||
#else
|
||||
strcpy(fmtstr2, "\n%18s");
|
||||
strlcpy(fmtstr2, "\n%18s", sizeof(fmtstr2));
|
||||
#endif
|
||||
/* Loop though all bytes and display them */
|
||||
|
||||
|
@@ -5,7 +5,8 @@
|
||||
* Copyright (c) 2011, B.ZaaR, All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
@@ -18,17 +19,17 @@
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* OR BUSINESS PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -114,7 +115,8 @@ static int bffree(FAR struct bfile_s *bf)
|
||||
|
||||
long fsize(FILE * fp)
|
||||
{
|
||||
long off, sz;
|
||||
long off;
|
||||
long sz;
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
@@ -211,14 +213,12 @@ FAR struct bfile_s *bfopen(char *name, char *mode)
|
||||
|
||||
/* Set file name */
|
||||
|
||||
if ((bf->name = malloc(strlen(name) + 1)) == NULL)
|
||||
if ((bf->name = strdup(name)) == NULL)
|
||||
{
|
||||
bffree(bf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(bf->name, name);
|
||||
|
||||
/* Open file */
|
||||
|
||||
if ((bf->fp = fopen(bf->name, mode)) == NULL)
|
||||
|
@@ -350,7 +350,7 @@ static int compose_name(FAR const char *fname, FAR char *oname, int namelen)
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(oname, fname);
|
||||
strlcpy(oname, fname, namelen);
|
||||
p = strstr(oname, ".lzf");
|
||||
if (p == NULL)
|
||||
{
|
||||
|
@@ -1080,11 +1080,11 @@ static int tcurses_vt100_setattributes(FAR struct termcurses_s *dev,
|
||||
|
||||
if (attrib & TCURS_ATTRIB_BOLD)
|
||||
{
|
||||
strcpy(str, g_setbold);
|
||||
strlcpy(str, g_setbold, sizeof(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(str, g_setnobold);
|
||||
strlcpy(str, g_setnobold, sizeof(str));
|
||||
}
|
||||
|
||||
if (attrib & TCURS_ATTRIB_BLINK)
|
||||
|
@@ -4035,7 +4035,7 @@ static void vi_cmd_mode(FAR struct vi_s *vi)
|
||||
{
|
||||
/* Emulate :wq */
|
||||
|
||||
strcpy(vi->scratch, "wq");
|
||||
strlcpy(vi->scratch, "wq", sizeof(vi->scratch));
|
||||
vi->cmdlen = 2;
|
||||
vi_parsecolon(vi);
|
||||
|
||||
|
Reference in New Issue
Block a user