diff options
| -rw-r--r-- | crypto/compat/getdelim.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/compat/getdelim.c b/crypto/compat/getdelim.c index 9bacf0c..bf4889f 100644 --- a/crypto/compat/getdelim.c +++ b/crypto/compat/getdelim.c | |||
| @@ -27,6 +27,8 @@ | |||
| 27 | * POSSIBILITY OF SUCH DAMAGE. | 27 | * POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | #include <errno.h> | ||
| 31 | #include <stdint.h> | ||
| 30 | #include <stdio.h> | 32 | #include <stdio.h> |
| 31 | #include <stdlib.h> | 33 | #include <stdlib.h> |
| 32 | 34 | ||
| @@ -66,6 +68,10 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp) | |||
| 66 | } | 68 | } |
| 67 | if (ptr + 2 >= eptr) { | 69 | if (ptr + 2 >= eptr) { |
| 68 | ssize_t d = ptr - *buf; | 70 | ssize_t d = ptr - *buf; |
| 71 | if (*bufsiz > SIZE_MAX / 2) { | ||
| 72 | errno = EOVERFLOW; | ||
| 73 | return -1; | ||
| 74 | } | ||
| 69 | nbufsiz = *bufsiz * 2; | 75 | nbufsiz = *bufsiz * 2; |
| 70 | if ((nbuf = realloc(*buf, nbufsiz)) == NULL) | 76 | if ((nbuf = realloc(*buf, nbufsiz)) == NULL) |
| 71 | return -1; | 77 | return -1; |
