From: David du Colombier <0intro@gmail.com> Date: Sun, 9 Aug 2015 20:21:20 +0000 (+0200) Subject: fix warnings reported by Coverity X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=3e9f31dac30ea1a05813fc48cd80bd90bf139268;p=proto%2Flibregexp.git fix warnings reported by Coverity regcomp.c:126 fixed_size_dest: You might overrun the 100 byte fixed-size string buf by copying s without checking the length regerror.c:11 fixed_size_dest: You might overrun the 132 byte fixed-size string buf by copying s without checking the length regexec:174 leaked_storage: Variable relist0 going out of scope leaks the storage it points to --- diff --git a/regcomp.c b/regcomp.c index 5b01d95..195d681 100644 --- a/regcomp.c +++ b/regcomp.c @@ -124,7 +124,7 @@ cant(char *s) { char buf[100]; strncpy(buf, "can't happen: ", sizeof(buf)); - strcat(buf, s); + strncat(buf, s, sizeof(buf)-1); rcerror(buf); } diff --git a/regerror.c b/regerror.c index c2e1826..e63f084 100644 --- a/regerror.c +++ b/regerror.c @@ -9,8 +9,8 @@ regerror(char *s) char buf[132]; strncpy(buf, "regerror: ", sizeof(buf)); - strcat(buf, s); - strcat(buf, "\n"); + strncat(buf, s, sizeof(buf)-1); + strncat(buf, "\n", sizeof(buf)-1); write(2, buf, strlen(buf)); exit(1); } diff --git a/regexec.c b/regexec.c index e2dadb8..b0f9c86 100644 --- a/regexec.c +++ b/regexec.c @@ -171,7 +171,7 @@ regexec2(Reprog *progp, /* program to run */ return -1; relist1 = malloc(BIGLISTSIZE*sizeof(Relist)); if(relist1 == NULL){ - free(relist1); + free(relist0); return -1; } j->relist[0] = relist0;