Avoiding strcpy usage, Make static analyzer happy

This commit is contained in:
Xinchen Hui 2011-08-09 09:35:42 +00:00
parent 7402dee014
commit 571427c7db
2 changed files with 13 additions and 1 deletions

12
ext/ereg/regex.patch Normal file
View File

@ -0,0 +1,12 @@
diff -u regex.orig/regerror.c regex/regerror.c
--- regex.orig/regerror.c 2011-08-09 17:31:11.000000000 +0800
+++ regex/regerror.c 2011-08-09 17:29:53.000000000 +0800
@@ -82,7 +82,7 @@
if (errcode&REG_ITOA) {
if (r->code >= 0)
- (void) strcpy(convbuf, r->name);
+ (void) strncpy(convbuf, r->name, 50);
else
sprintf(convbuf, "REG_0x%x", target);
assert(strlen(convbuf) < sizeof(convbuf));

View File

@ -82,7 +82,7 @@ size_t errbuf_size)
if (errcode&REG_ITOA) {
if (r->code >= 0)
(void) strcpy(convbuf, r->name);
(void) strncpy(convbuf, r->name, 50);
else
sprintf(convbuf, "REG_0x%x", target);
assert(strlen(convbuf) < sizeof(convbuf));