php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
gd_security.c
Go to the documentation of this file.
1/*
2 * gd_security.c
3 *
4 * Implements buffer overflow check routines.
5 *
6 * Written 2004, Phil Knirsch.
7 * Based on netpbm fixes by Alan Cox.
8 *
9 */
10
11#ifdef HAVE_CONFIG_H
12#include "config.h"
13#endif
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <limits.h>
18#include "gd.h"
19#include "gd_errors.h"
20
21int overflow2(int a, int b)
22{
23 if(a <= 0 || b <= 0) {
24 gd_error("One parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
25 return 1;
26 }
27 if(a > INT_MAX / b) {
28 gd_error("Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
29 return 1;
30 }
31 return 0;
32}
int overflow2(int a, int b)
Definition gd_security.c:21
void gd_error(const char *format,...)
Definition gd.c:103
#define INT_MAX
Definition php.h:237
$obj a
Definition test.php:84