1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-10 22:13:00 +00:00

Fixed possible integer overflow with option -b

This commit is contained in:
Gerhard Rieger 2020-10-13 20:08:04 +02:00
parent 0c65370ae5
commit 8e6b341f59
4 changed files with 66 additions and 2 deletions

View file

@ -779,6 +779,10 @@ int _socat(void) {
#endif /* WITH_FILAN */
/* when converting nl to crnl, size might double */
if (socat_opts.bufsiz > (SIZE_MAX-1)/2) {
Error2("buffer size option (-b) to big - "F_Zu" (max is "F_Zu")", socat_opts.bufsiz, (SIZE_MAX-1)/2);
socat_opts.bufsiz = (SIZE_MAX-1)/2;
}
buff = Malloc(2*socat_opts.bufsiz+1);
if (buff == NULL) return -1;