stas Sat Feb 24 03:08:06 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/exif exif.c
Log:
use safe allocations
http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.173.2.5.2.12&r2=1.173.2.5.2.13&diff_format=u
Index: php-src/ext/exif/exif.c
diff -u php-src/ext/exif/exif.c:1.173.2.5.2.12
php-src/ext/exif/exif.c:1.173.2.5.2.13
--- php-src/ext/exif/exif.c:1.173.2.5.2.12 Sat Feb 24 02:17:24 2007
+++ php-src/ext/exif/exif.c Sat Feb 24 03:08:05 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: exif.c,v 1.173.2.5.2.12 2007/02/24 02:17:24 helly Exp $ */
+/* $Id: exif.c,v 1.173.2.5.2.13 2007/02/24 03:08:05 stas Exp $ */
/* ToDos
*
@@ -84,6 +84,9 @@
#ifndef safe_emalloc
# define safe_emalloc(a,b,c) emalloc((a)*(b)+(c))
#endif
+#ifndef safe_erealloc
+# define safe_erealloc(p,a,b,c) erealloc(p, (a)*(b)+(c))
+#endif
#ifndef TRUE
# define TRUE 1
@@ -139,7 +142,7 @@
};
/* }}} */
-#define EXIF_VERSION "1.4 $Id: exif.c,v 1.173.2.5.2.12 2007/02/24 02:17:24
helly Exp $"
+#define EXIF_VERSION "1.4 $Id: exif.c,v 1.173.2.5.2.13 2007/02/24 03:08:05
stas Exp $"
/* {{{ PHP_MINFO_FUNCTION
*/
@@ -1597,7 +1600,7 @@
file_section *tmp;
int count = ImageInfo->file.count;
- tmp = erealloc(ImageInfo->file.list, (count+1)*sizeof(file_section));
+ tmp = safe_erealloc(ImageInfo->file.list, (count+1),
sizeof(file_section), 0);
ImageInfo->file.list = tmp;
ImageInfo->file.list[count].type = 0xFFFF;
ImageInfo->file.list[count].data = NULL;
@@ -1629,7 +1632,7 @@
EXIF_ERRLOG_FSREALLOC(ImageInfo)
return -1;
}
- tmp = erealloc(ImageInfo->file.list[section_index].data, size);
+ tmp = safe_erealloc(ImageInfo->file.list[section_index].data, 1, size,
0);
ImageInfo->file.list[section_index].data = tmp;
ImageInfo->file.list[section_index].size = size;
return 0;
@@ -1669,7 +1672,7 @@
return;
}
- list = erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1)*sizeof(image_info_data));
+ list = safe_erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1), sizeof(image_info_data), 0);
image_info->info_list[section_index].list = list;
info_data =
&image_info->info_list[section_index].list[image_info->info_list[section_index].count];
@@ -1807,7 +1810,7 @@
image_info_data *info_data;
image_info_data *list;
- list = erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1)*sizeof(image_info_data));
+ list = safe_erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1), sizeof(image_info_data), 0);
image_info->info_list[section_index].list = list;
info_data =
&image_info->info_list[section_index].list[image_info->info_list[section_index].count];
@@ -1830,7 +1833,7 @@
image_info_data *list;
if (value) {
- list = erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1)*sizeof(image_info_data));
+ list = safe_erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1), sizeof(image_info_data), 0);
image_info->info_list[section_index].list = list;
info_data =
&image_info->info_list[section_index].list[image_info->info_list[section_index].count];
info_data->tag = TAG_NONE;
@@ -1875,7 +1878,7 @@
image_info_data *list;
if (value) {
- list = erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1)*sizeof(image_info_data));
+ list = safe_erealloc(image_info->info_list[section_index].list,
(image_info->info_list[section_index].count+1), sizeof(image_info_data), 0);
image_info->info_list[section_index].list = list;
info_data =
&image_info->info_list[section_index].list[image_info->info_list[section_index].count];
info_data->tag = TAG_NONE;
@@ -2489,7 +2492,7 @@
}
}
new_move = new_size;
- new_data = erealloc(ImageInfo->Thumbnail.data,
ImageInfo->Thumbnail.size+new_size);
+ new_data = safe_erealloc(ImageInfo->Thumbnail.data, 1,
ImageInfo->Thumbnail.size, new_size);
ImageInfo->Thumbnail.data = new_data;
memmove(ImageInfo->Thumbnail.data + new_move,
ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size);
ImageInfo->Thumbnail.size += new_size;
@@ -2985,7 +2988,7 @@
case TAG_XP_AUTHOR:
case TAG_XP_KEYWORDS:
case TAG_XP_SUBJECT:
- tmp_xp =
(xp_field_type*)erealloc(ImageInfo->xp_fields.list,
sizeof(xp_field_type)*(ImageInfo->xp_fields.count+1));
+ tmp_xp =
(xp_field_type*)safe_erealloc(ImageInfo->xp_fields.list,
(ImageInfo->xp_fields.count+1), sizeof(xp_field_type), 0);
ImageInfo->sections_found |= FOUND_WINXP;
ImageInfo->xp_fields.list = tmp_xp;
ImageInfo->xp_fields.count++;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php