summaryrefslogtreecommitdiffstats
path: root/tools/h5import
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-10 17:43:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-10 17:43:14 (GMT)
commit9d06256018fbebbefa08879ae9f16696a5bbef19 (patch)
treedb84f4d812d122c8c9fafbcc4b828fc12cbf6a8e /tools/h5import
parenta4750dfae7e187f95c4515939968e6fce880efed (diff)
downloadhdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.zip
hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.tar.gz
hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.tar.bz2
[svn-r17987] Description:
Bring r17945:17986 from trunk to revise_chunks branch (needs to have autotools files regenerated before testing, those will be checked in in a few minutes)
Diffstat (limited to 'tools/h5import')
-rwxr-xr-xtools/h5import/h5import.c25
-rwxr-xr-xtools/h5import/h5import.h3
2 files changed, 22 insertions, 6 deletions
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index 3818829..60ef494 100755
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -1587,16 +1587,29 @@ static int
parsePathInfo(struct path_info *path, char *temp)
{
const char delimiter[] = "/";
- char *token = (char*) malloc(255*sizeof(char));
+ char *token;
int i=0;
+ const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n";
+
+ token = HDstrtok (temp, delimiter);
+ if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH)
+ {
+ (void) fprintf(stderr, err1);
+ return (-1);
+ }
+ HDstrcpy(path->group[i++],token);
- HDstrcpy(path->group[i++],HDstrtok (temp, delimiter));
while (1)
{
token = HDstrtok (NULL, delimiter);
if (token == NULL)
break;
+ if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH)
+ {
+ (void) fprintf(stderr, err1);
+ return (-1);
+ }
HDstrcpy(path->group[i++],token);
}
path->count = i;
@@ -1608,11 +1621,12 @@ parseDimensions(struct Input *in, char *strm)
{
const char delimiter[] = ",";
char temp[255];
- char *token = (char*) malloc(255*sizeof(char));
+ char *token;
int i=0;
const char *err1 = "Unable to allocate dynamic memory.\n";
- HDstrcpy(temp, strm);
+ HDstrncpy(temp, strm, sizeof(temp));
+ temp[sizeof(temp)-1] = '\0';
HDstrtok (temp, delimiter);
while (1)
@@ -1631,7 +1645,8 @@ parseDimensions(struct Input *in, char *strm)
}
i=0;
- HDstrcpy(temp, strm);
+ HDstrncpy(temp, strm, sizeof(temp));
+ temp[sizeof(temp)-1] = '\0';
in->sizeOfDimension[i++] = HDstrtol(HDstrtok (temp, delimiter), NULL, BASE_10);
while (1)
diff --git a/tools/h5import/h5import.h b/tools/h5import/h5import.h
index c43b0cf..cbc6bf2 100755
--- a/tools/h5import/h5import.h
+++ b/tools/h5import/h5import.h
@@ -38,6 +38,7 @@
#define ERR 20 /* invalid token */
#define MAX_GROUPS_IN_PATH 20
+#define MAX_PATH_NAME_LENGTH 255
#define NUM_KEYS 14
#define MIN_NUM_DIMENSION 1
#define MAX_NUM_DIMENSION 32
@@ -73,7 +74,7 @@
struct path_info
{
- char group[MAX_GROUPS_IN_PATH][255];
+ char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH];
int count;
};