Date: Sat, 26 Jan 2019 21:30:26 +0000 (UTC) From: Stefan Esser <se@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343480 - head/lib/libfigpar Message-ID: <201901262130.x0QLUQnf002874@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: se Date: Sat Jan 26 21:30:26 2019 New Revision: 343480 URL: https://svnweb.freebsd.org/changeset/base/343480 Log: Silence Clang Scan warning about potentially unsafe use of strcpy. While this is a false positive, the use of strdup() simplifies the code. MFC after: 2 weeks Modified: head/lib/libfigpar/string_m.c Modified: head/lib/libfigpar/string_m.c ============================================================================== --- head/lib/libfigpar/string_m.c Sat Jan 26 20:43:28 2019 (r343479) +++ head/lib/libfigpar/string_m.c Sat Jan 26 21:30:26 2019 (r343480) @@ -119,10 +119,9 @@ replaceall(char *source, const char *find, const char /* If replace is longer than find, we'll need to create a temp copy */ if (rlen > flen) { - temp = malloc(slen + 1); - if (errno != 0) /* could not allocate memory */ + temp = strdup(source); + if (temp == NULL) /* could not allocate memory */ return (-1); - strcpy(temp, source); } else temp = source;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901262130.x0QLUQnf002874>