[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)
This commit is contained in:
MuQun Yang 2000-12-22 14:03:00 -05:00
parent ebe4c545e1
commit 7332a1934e
5 changed files with 25 additions and 9 deletions

View File

@ -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){

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;