helly Sat Feb 24 18:37:47 2007 UTC
Modified files:
/php-src/ext/exif exif.c
Log:
- MFB Synch
http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.192&r2=1.193&diff_format=u
Index: php-src/ext/exif/exif.c
diff -u php-src/ext/exif/exif.c:1.192 php-src/ext/exif/exif.c:1.193
--- php-src/ext/exif/exif.c:1.192 Sat Feb 24 16:25:53 2007
+++ php-src/ext/exif/exif.c Sat Feb 24 18:37:46 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: exif.c,v 1.192 2007/02/24 16:25:53 helly Exp $ */
+/* $Id: exif.c,v 1.193 2007/02/24 18:37:46 helly 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.192 2007/02/24 16:25:53 helly Exp $"
+#define EXIF_VERSION "1.4 $Id: exif.c,v 1.193 2007/02/24 18:37:46 helly Exp $"
/* {{{ PHP_MINFO_FUNCTION
*/
@@ -999,27 +1002,24 @@
break;
}
if (ret && len) {
- strncpy(ret, tag_table[i].Desc, abs(len));
- if (len<0) {
- len = -len;
- ret[len-1]='\0';
- for(i=strlen(ret);i<len;i++)ret[i]=' ';
+ strlcpy(ret, tag_table[i].Desc, abs(len));
+ if (len < 0) {
+ memset(ret + strlen(ret), ' ', -len -
strlen(ret) - 1);
+ ret[-len - 1] = '\0';
}
- ret[len-1]='\0';
return ret;
}
return tag_table[i].Desc;
}
}
+
if (ret && len) {
snprintf(tmp, sizeof(tmp), "UndefinedTag:0x%04X", tag_num);
- strncpy(ret, tmp, abs(len));
- if (len<0) {
- len = -len;
- ret[len-1]='\0';
- for(i=strlen(ret);i<len;i++)ret[i]=' ';
+ strlcpy(ret, tmp, abs(len));
+ if (len < 0) {
+ memset(ret + strlen(ret), ' ', -len - strlen(ret) - 1);
+ ret[-len - 1] = '\0';
}
- ret[len-1]='\0';
return ret;
}
return "";
@@ -1597,7 +1597,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;
@@ -1606,7 +1606,7 @@
if (!size) {
data = NULL;
} else if (data == NULL) {
- data = emalloc(size);
+ data = safe_emalloc(size, 1, 0);
}
ImageInfo->file.list[count].type = type;
ImageInfo->file.list[count].data = data;
@@ -1629,7 +1629,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 +1669,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];
@@ -1798,7 +1798,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];
@@ -1821,7 +1821,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;
@@ -1862,7 +1862,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;
@@ -2362,7 +2362,7 @@
image_info_value *info_value;
byte_count = php_tiff_bytes_per_format[info_data->format] *
info_data->length;
- value_ptr = emalloc(max(byte_count, 4));
+ value_ptr = safe_emalloc(max(byte_count, 4), 1, 0);
memset(value_ptr, 0, 4);
if (!info_data->length) {
return value_ptr;
@@ -2468,7 +2468,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;
@@ -2854,7 +2854,7 @@
}
if (byte_count>sizeof(cbuf)) {
/* mark as outside range and get buffer */
- value_ptr = emalloc(byte_count);
+ value_ptr = safe_emalloc(byte_count, 1, 0);
outside = value_ptr;
} else {
/*
@@ -2964,7 +2964,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