summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2000-12-22 19:03:00 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2000-12-22 19:03:00 (GMT)
commit7332a1934e1394770c98ba129d92cf2da467ab88 (patch)
tree1189309dac3bc2c48495e4f318cdfc8fb18efc2b /tools
parentebe4c545e1f4286f7ddd6219bfdcf5d7c23d9364 (diff)
downloadhdf5-7332a1934e1394770c98ba129d92cf2da467ab88.zip
hdf5-7332a1934e1394770c98ba129d92cf2da467ab88.tar.gz
hdf5-7332a1934e1394770c98ba129d92cf2da467ab88.tar.bz2
[svn-r3193]
Purpose: bug fix Description: Zeroing out all memory buffer before it is being used. Solution: using h4toh5ZeroMemory function Platforms tested: linux(eirene), arabica(sun 2.7)
Diffstat (limited to 'tools')
-rw-r--r--tools/h4toh5image.c8
-rw-r--r--tools/h4toh5main.c4
-rw-r--r--tools/h4toh5sds.c5
-rw-r--r--tools/h4toh5util.c5
-rw-r--r--tools/h4toh5vgroup.c12
5 files changed, 25 insertions, 9 deletions
diff --git a/tools/h4toh5image.c b/tools/h4toh5image.c
index 0f779a3..f3d41dc 100644
--- a/tools/h4toh5image.c
+++ b/tools/h4toh5image.c
@@ -84,7 +84,13 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
hsize_t h5dims[2];
herr_t ret;
hid_t create_plist;
-
+
+ /* zeroing out memory.*/
+
+ h4toh5_ZeroMemory(image_name,MAX_GR_NAME);
+ h4toh5_ZeroMemory(image_class,MAX_GR_NAME);
+ h4toh5_ZeroMemory(grlabel,MAX_GR_NAME);
+
/* Obtain information of the image.*/
if(GRgetchunkinfo(ri_id,&c_def_out,&c_flags)==FAIL){
diff --git a/tools/h4toh5main.c b/tools/h4toh5main.c
index 25dc9e5..c936b1b 100644
--- a/tools/h4toh5main.c
+++ b/tools/h4toh5main.c
@@ -934,7 +934,7 @@ int h4toh5vgrings(int32 file_id,int32 sd_id,hid_t h5group,hid_t h5_dimg,hid_t h5
/* do nothing for those predefined attribute.*/
- if(vgroup_class != NULL) {
+ if(vgroup_class[0] != '\0') {
if(strcmp(vgroup_class,_HDF_ATTRIBUTE)==0) {
ref_num = Vgetid(file_id,ref_num);
@@ -979,7 +979,7 @@ int h4toh5vgrings(int32 file_id,int32 sd_id,hid_t h5group,hid_t h5_dimg,hid_t h5
}
}
- if(vgroup_name != NULL) {
+ if(vgroup_name[0] != '\0') {
if(strcmp(vgroup_name,GR_NAME)==0) {
ref_num = Vgetid(file_id,ref_num);
Vdetach(vgroup_id);
diff --git a/tools/h4toh5sds.c b/tools/h4toh5sds.c
index 3781e63..eb90e4c 100644
--- a/tools/h4toh5sds.c
+++ b/tools/h4toh5sds.c
@@ -85,7 +85,10 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
char* h5csds_name;
herr_t ret;
+ /* zeroing out the memory for sdsname and sdslabel.*/
+ h4toh5_ZeroMemory(sdsname,MAX_NC_NAME);
+ h4toh5_ZeroMemory(sdslabel,MAX_NC_NAME);
/* check whether the sds is empty. */
if(SDcheckempty(sds_id,&sds_empty)== FAIL) {
@@ -417,7 +420,7 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
return FAIL;
}
- if(sdsname != NULL) {
+ if(sdsname[0] != '\0') {
if(h4_transpredattrs(h5dset,HDF4_OBJECT_NAME,sdsname)==FAIL){
free(sds_start);
free(sds_edge);
diff --git a/tools/h4toh5util.c b/tools/h4toh5util.c
index ea9c452..64e32cf 100644
--- a/tools/h4toh5util.c
+++ b/tools/h4toh5util.c
@@ -526,13 +526,16 @@ int conv_int_str(uint16 num, char* str_num) {
/* the maximum reference number is 65536. */
+
if(str_num == NULL) {
printf(" memory for str_num should be allocated.\n");
return FAIL;
}
- sprintf(str_num,"%d",num);
+ /* Adding this line will cause problems, investigating this later.
+h4toh5_ZeroMemory(str_num,strlen(str_num)+1);*/
+ sprintf(str_num,"%d",num);
return SUCCEED;
}
diff --git a/tools/h4toh5vgroup.c b/tools/h4toh5vgroup.c
index 81acecc..92a6735 100644
--- a/tools/h4toh5vgroup.c
+++ b/tools/h4toh5vgroup.c
@@ -65,7 +65,7 @@ int Vgroup_h4_to_h5(int32 file_id,int32 vgroup_id,int32 sd_id,hid_t h5_group,hid
int32 num_gobjects;
int i;
- char refstr[5];
+ char refstr[MAXREF_LENGTH];
char vgroup_class[VGNAMELENMAX];
char vgroup_name[VGNAMELENMAX];
@@ -74,6 +74,10 @@ int Vgroup_h4_to_h5(int32 file_id,int32 vgroup_id,int32 sd_id,hid_t h5_group,hid
int check_vgname;
hid_t h5_pgroup;
+ /*zeroing out memory for vgroup_class and vgroup_name */
+ h4toh5_ZeroMemory(vgroup_class,VGNAMELENMAX);
+ h4toh5_ZeroMemory(vgroup_name,VGNAMELENMAX);
+
vgroup_tag = VQuerytag(vgroup_id);
if(vgroup_tag == FAIL) {
printf("error in obtaining vgroup tag.\n");
@@ -392,7 +396,7 @@ int convert_vdata(int32 file_id,int32 obj_ref,char * h5pgroup_name,
int check_vdata;
int check_vdname;
int32 istat;
- char refstr[5];
+ char refstr[MAXREF_LENGTH];
char cvdata_name[VGNAMELENMAX];
char* cor_cvdataname;
char* h5cvdata_name;
@@ -544,7 +548,7 @@ int convert_sds(int32 file_id,int32 sd_id,int32 obj_ref,char * h5pgroup_name,
char* cor_sdsname;
int check_sds;
int check_sdsname;
- char refstr[5];
+ char refstr[MAXREF_LENGTH];
char* h5csds_name;
char* h5lsds_name;
@@ -677,7 +681,7 @@ int convert_image(int32 file_id,int32 obj_ref,char * h5pgroup_name,
int32 istat;
char* h5cimage_name;
char* h5limage_name;
- char refstr[5];
+ char refstr[MAXREF_LENGTH];
char image_name[MAX_GR_NAME];
char* cor_imagename;