From 1ea3728187a555770c3c83752bd86639b1752a99 Mon Sep 17 00:00:00 2001 From: Alfons Hoogervorst Date: Sun, 23 Dec 2001 17:37:53 +0000 Subject: [PATCH] be a little bit more stringent in checking input strings --- ChangeLog.claws | 5 +++++ configure.in | 2 +- src/string_match.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index a1ea5083e..275142770 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,8 @@ +2001-12-23 [alfons] 0.6.6claws13 + + * src/string_match.c + validate input strings a little bit more + 2001-12-23 [alfons] 0.6.6claws12 * src/Makefile.am diff --git a/configure.in b/configure.in index f4a26f69c..aeebf2887 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ MINOR_VERSION=6 MICRO_VERSION=6 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws12 +EXTRA_VERSION=claws13 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl diff --git a/src/string_match.c b/src/string_match.c index 2e4ca3cca..114fb593c 100644 --- a/src/string_match.c +++ b/src/string_match.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +#include #include "string_match.h" @@ -28,6 +28,9 @@ int string_match_regexp(char * txt, char * rexp, regex_t re; int problem; + g_return_val_if_fail(txt, 0); + g_return_val_if_fail(rexp, 0); + problem = regcomp(&re, rexp, cflags); if (problem == 0) { problem = regexec(&re, txt, size, matches, eflags); @@ -41,6 +44,9 @@ int string_remove_match(char * txt, char * rexp, int cflags, int eflags) regmatch_t matches[STRING_MATCH_MR_SIZE]; int foundp; + g_return_val_if_fail(txt, -1); + g_return_val_if_fail(rexp, -1); + if (strlen(txt) > 0 && strlen(rexp) > 0) { foundp = string_match_regexp(txt, rexp, STRING_MATCH_MR_SIZE, matches, cflags, eflags); @@ -66,6 +72,9 @@ int string_remove_all_matches(char * txt, char * rexp, int cflags, int eflags) int pos = 0; int pos0 = pos; + g_return_val_if_fail(txt, 0); + g_return_val_if_fail(rexp, 0); + while (pos0 >= 0 && pos < strlen(txt) && strlen(txt) > 0) { /* printf("%s %d:%d\n", txt, pos0, pos); */ pos0 = string_remove_match(txt + pos, rexp, cflags, eflags); -- 2.25.1