summaryrefslogtreecommitdiffstats
path: root/perform
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2008-12-09 04:11:37 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2008-12-09 04:11:37 (GMT)
commit5218c4001a0d73d3029327f7a771001d149467b1 (patch)
treec0ccab21b0b4e95b30d80d5206e5f512acb2b877 /perform
parent27c239c2d17d33f9edd6546b664bc2720c8c34c7 (diff)
downloadhdf5-5218c4001a0d73d3029327f7a771001d149467b1.zip
hdf5-5218c4001a0d73d3029327f7a771001d149467b1.tar.gz
hdf5-5218c4001a0d73d3029327f7a771001d149467b1.tar.bz2
[svn-r16172] Code clean up.
Function get_unique_name() had potential string overflow problem. Fixed. Also removed some unused macros. Tested by h5committest.
Diffstat (limited to 'perform')
-rw-r--r--perform/zip_perf.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/perform/zip_perf.c b/perform/zip_perf.c
index d7b75c7..d1d36b4 100644
--- a/perform/zip_perf.c
+++ b/perform/zip_perf.c
@@ -69,8 +69,6 @@
# define GZ_SUFFIX ".gz"
#endif /* GZ_SUFFIX */
-#define SUFFIX_LEN (sizeof(GZ_SUFFIX) - 1)
-
#define ONE_KB 1024
#define ONE_MB (ONE_KB * ONE_KB)
#define ONE_GB (ONE_MB * ONE_KB)
@@ -88,8 +86,6 @@
#define FALSE (!TRUE)
#endif /* FALSE */
-#define BUFLEN (16 * ONE_KB)
-#define MAX_NAME_LEN ONE_KB
/* internal variables */
static const char *prog;
@@ -321,25 +317,28 @@ uncompress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source,
static void
get_unique_name(void)
{
- const char *prefix = "", *tmpl = "zip_perf.data";
+ const char *prefix = NULL, *tmpl = "zip_perf.data";
const char *env = getenv("HDF5_PREFIX");
- if (env) {
+ if (env)
prefix = env;
- strcat(prefix, "/");
- }
- if (option_prefix) {
+ if (option_prefix)
prefix = option_prefix;
- strcat(prefix, "/");
- }
- filename = calloc(1, strlen(prefix) + strlen(tmpl) + 1);
+ if (prefix)
+ /* 2 = 1 for '/' + 1 for null terminator */
+ filename = (char *) HDmalloc(strlen(prefix) + strlen(tmpl) + 2);
+ else
+ filename = (char *) HDmalloc(strlen(tmpl) + 1);
if (!filename)
error("out of memory");
- strcpy(filename, prefix);
+ if (prefix){
+ strcpy(filename, prefix);
+ strcat(filename, "/");
+ }
strcat(filename, tmpl);
}