string/lib_strcpy.c:87:15: runtime error: signed integer overflow: -2132367969 - 16843009 cannot be represented in type 'long int'
#0 0x48e77096 in strcpy string/lib_strcpy.c:87
#1 0x535b6ea4 in libconfig_strbuf_append_string libconfig/lib/strbuf.c:60
#2 0x53ad7f52 in libconfig_yyparse /home/ygc/ssd/x4b-sim/external/libconfig/grammar.y:186
#3 0x5358d281 in __config_read libconfig/lib/libconfig.c:561
#4 0x5358dea0 in config_read_file libconfig/lib/libconfig.c:677
#5 0x52cdd0a5 in tts_vendor_list_get src/vendor.c:114
#6 0x52cde739 in default_tts_vendor_get src/vendor.c:356
#7 0x52a07e1d in vendorswitch_init src/vendorswitch/vendorswitch.c:501
#8 0x52444fb9 in mico_misc_main /home/ygc/ssd/x4b-sim/vendor/xiaomi/miai/mico_misc/instance/main.c:72
#9 0x48bee720 in nxtask_startup sched/task_startup.c:70
#10 0x48b41eb4 in nxtask_start task/task_start.c:112
#11 0x48c1ef3d in pre_start sim/sim_initialstate.c:52
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
111 lines
3.5 KiB
C
111 lines
3.5 KiB
C
/****************************************************************************
|
|
* libs/libc/string/lib_strcpy.c
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "libc.h"
|
|
|
|
/****************************************************************************
|
|
* Pre-processor Definitions
|
|
****************************************************************************/
|
|
|
|
#ifdef CONFIG_LIBC_STRING_OPTIMIZE
|
|
/* Nonzero if either x or y is not aligned on a "long" boundary. */
|
|
|
|
#define UNALIGNED(x, y) \
|
|
(((long)(uintptr_t)(x) & (sizeof(long) - 1)) | ((long)(uintptr_t)(y) & (sizeof(long) - 1)))
|
|
|
|
/* Macros for detecting endchar */
|
|
|
|
#if LONG_MAX == 2147483647
|
|
# define DETECTNULL(x) (((x) - 0x01010101) & ~(x) & 0x80808080)
|
|
#elif LONG_MAX == 9223372036854775807
|
|
/* Nonzero if x (a long int) contains a NULL byte. */
|
|
|
|
# define DETECTNULL(x) (((x) - 0x0101010101010101) & ~(x) & 0x8080808080808080)
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: strcpy
|
|
*
|
|
* Description:
|
|
* Copies the string pointed to by 'src' (including the terminating NUL
|
|
* character) into the array pointed to by 'des'.
|
|
*
|
|
* Returned Value:
|
|
* The strcpy() function returns the 'dest' pointer
|
|
*
|
|
****************************************************************************/
|
|
|
|
#if !defined(CONFIG_LIBC_ARCH_STRCPY) && defined(LIBC_BUILD_STRCPY)
|
|
#undef strcpy /* See mm/README.txt */
|
|
nosanitize_address
|
|
FAR char *strcpy(FAR char *dest, FAR const char *src)
|
|
{
|
|
#ifdef CONFIG_LIBC_STRING_OPTIMIZE
|
|
FAR char *dst0 = dest;
|
|
FAR const char *src0 = src;
|
|
FAR unsigned long *aligned_dst;
|
|
FAR const unsigned long *aligned_src;
|
|
|
|
/* If SRC or DEST is unaligned, then copy bytes. */
|
|
|
|
if (!UNALIGNED(src0, dst0))
|
|
{
|
|
aligned_dst = (FAR unsigned long *)dst0;
|
|
aligned_src = (FAR unsigned long *)src0;
|
|
|
|
/* SRC and DEST are both "long int" aligned, try to do "long int"
|
|
* sized copies.
|
|
*/
|
|
|
|
while (!DETECTNULL(*aligned_src))
|
|
{
|
|
*aligned_dst++ = *aligned_src++;
|
|
}
|
|
|
|
dst0 = (FAR char *)aligned_dst;
|
|
src0 = (FAR char *)aligned_src;
|
|
}
|
|
|
|
while ((*dst0++ = *src0++) != '\0');
|
|
|
|
return dest;
|
|
#else
|
|
FAR char *tmp = dest;
|
|
while ((*dest++ = *src++) != '\0');
|
|
return tmp;
|
|
#endif
|
|
}
|
|
#endif
|