diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2021-03-21 03:51:08 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2021-03-21 03:51:08 +0000 |
commit | 15520de3aa5100b148757e550b87a73798192b92 (patch) | |
tree | 363ed16b30b0522a62a14d59fb1b6417a843db2d /Str.h | |
parent | Update ChangeLog (diff) | |
download | w3m-15520de3aa5100b148757e550b87a73798192b92.tar.gz w3m-15520de3aa5100b148757e550b87a73798192b92.zip |
Check STR_SIZE_MAX in Strcat_char
Diffstat (limited to 'Str.h')
-rw-r--r-- | Str.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -17,6 +17,7 @@ #define GC_STR_H #include <stdio.h> #include <string.h> +#include <limits.h> #ifdef __EMX__ #define strcasecmp stricmp #define strncasecmp strnicmp @@ -66,7 +67,8 @@ Str Strfgetall(FILE *); void Strgrow(Str s); -#define Strcat_char(x,y) (((x)->length+1>=(x)->area_size)?Strgrow(x),0:0,(x)->ptr[(x)->length++]=(y),(x)->ptr[(x)->length]=0) +#define STR_SIZE_MAX (INT_MAX / 32) +#define Strcat_char(x,y) (((x)->length+1>=STR_SIZE_MAX)?0:(((x)->length+1>=(x)->area_size)?Strgrow(x),0:0,(x)->ptr[(x)->length++]=(y),(x)->ptr[(x)->length]=0)) #define Strcmp(x,y) strcmp((x)->ptr,(y)->ptr) #define Strcmp_charp(x,y) strcmp((x)->ptr,(y)) #define Strncmp(x,y,n) strncmp((x)->ptr,(y)->ptr,(n)) |