aboutsummaryrefslogtreecommitdiffstats
path: root/indep.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2021-03-27 11:04:56 +0000
committerTatsuya Kinoshita <tats@debian.org>2021-03-27 11:04:56 +0000
commitd0a30912c83f90595ded23fd3924ba826f498b16 (patch)
tree77f26ffed44325f92855f7a4f41bf86f1f21dd86 /indep.c
parentUpdate ChangeLog (diff)
downloadw3m-d0a30912c83f90595ded23fd3924ba826f498b16.tar.gz
w3m-d0a30912c83f90595ded23fd3924ba826f498b16.zip
Fix potential integer overflow in allocStr
Diffstat (limited to 'indep.c')
-rw-r--r--indep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/indep.c b/indep.c
index 4957c67..055e19e 100644
--- a/indep.c
+++ b/indep.c
@@ -104,6 +104,8 @@ allocStr(const char *s, int len)
return NULL;
if (len < 0)
len = strlen(s);
+ if (len < 0 || len >= STR_SIZE_MAX)
+ len = STR_SIZE_MAX - 1;
ptr = NewAtom_N(char, len + 1);
if (ptr == NULL) {
fprintf(stderr, "fm: Can't allocate string. Give me more memory!\n");