diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/h5diff_array.c | 6 | ||||
-rw-r--r-- | tools/lib/h5diff_attr.c | 2 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 2 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 3 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump_ddl.c | 24 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump_xml.c | 13 | ||||
-rw-r--r-- | tools/src/h5import/h5import.c | 7 | ||||
-rw-r--r-- | tools/src/h5perf/sio_perf.c | 2 |
9 files changed, 40 insertions, 23 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index c3886c8..c465b7a 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -1855,7 +1855,7 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } @@ -1902,7 +1902,7 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } @@ -1949,7 +1949,7 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 642b57b..80b206f 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -292,7 +292,7 @@ build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t **table_out, } if (opts->mode_verbose_level >= 1) - parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n", + parallel_print("Attributes status: %zu common, %zu only in obj1, %zu only in obj2\n", table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, table_lp->nattrs_only1, table_lp->nattrs_only2); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index bc4ac36..dee0d4d 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -767,7 +767,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec * as TRUE, we should return failure now since the file couldn't be opened with * the VFL driver that was set on the FAPL by the caller. */ - if (fid < 0 && use_specific_driver) + if (use_specific_driver) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to open file using specified FAPL"); for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) { diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 0a82993..4ca995e 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -2481,7 +2481,7 @@ found_string_type: ctx->need_prefix = TRUE; h5tools_str_reset(buffer); - h5tools_str_append(buffer, "OPAQUE_SIZE \"%s\";", size); + h5tools_str_append(buffer, "OPAQUE_SIZE \"%zu\";", size); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); } @@ -2988,7 +2988,7 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s %d %s", OBJID, BEGIN, oid, END); + h5tools_str_append(&buffer, "%s %s %" PRId64 " %s", OBJID, BEGIN, oid, END); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 4fd31e0..8a592f7 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -258,7 +258,8 @@ h5tools_str_fmt(h5tools_str_t *str /*in,out*/, size_t start, const char *fmt) HDassert(temp); } - HDstrncpy(temp, str->s + start, n); + HDstrncpy(temp, str->s + start, n - 1); + temp[n - 1] = '\0'; } /* Reset the output string and append a formatted version */ diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 3a9a939..e0bd63e 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -1295,7 +1295,7 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a j = (int)HDstrlen(op_name) - 1; /* find the last / */ while (j >= 0) { - if (op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\'))) + if (op_name[j] == '/' && (j == 0 || (op_name[j - 1] != '\\'))) break; j--; } @@ -1320,13 +1320,21 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a ret = FAIL; } else { + size_t buffer_space = w - 1; + HDmemset(obj_name, '\0', w); if (op_name[0] != '/') { - HDstrncat(obj_name, buf, u + 1); - if (buf[u - 1] != '/') - HDstrncat(obj_name, "/", (size_t)2); + HDstrncat(obj_name, buf, buffer_space); + buffer_space -= MIN(buffer_space, u); + + if (buf[u - 1] != '/') { + HDstrncat(obj_name, "/", buffer_space); + buffer_space -= MIN(buffer_space, 2); + } } - HDstrncat(obj_name, op_name, v + 1); + + HDstrncat(obj_name, op_name, buffer_space); + buffer_space -= MIN(buffer_space, v); handle_attributes(oid, obj_name, NULL, 0, NULL); HDfree(obj_name); @@ -1396,10 +1404,10 @@ lnk_search(const char *path, const H5L_info_t *li, void *_op_data) else { if (k == 2) { HDstrcpy(search_name, "/"); - HDstrncat(search_name, op_name, search_len + 1); + HDstrcat(search_name, op_name); } else - HDstrncpy(search_name, op_name, search_len + 1); + HDstrcpy(search_name, op_name); search_name[search_len + k - 1] = '\0'; if (HDstrcmp(path, search_name) == 0) { @@ -1508,7 +1516,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 /* find the last / */ while (j >= 0) { - if (attr[j] == '/' && (j == 0 || (j > 0 && attr[j - 1] != '\\'))) + if (attr[j] == '/' && (j == 0 || (attr[j - 1] != '\\'))) break; j--; } diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 61c2ce2..ec14fdc 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -588,6 +588,8 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) if (outlen < 22) return 1; + H5_CHECK_OVERFLOW(outlen, int, size_t); + objno = ref_path_table_lookup(str); if (objno == HADDR_UNDEF) { if (HDstrlen(str) == 0) { @@ -595,7 +597,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) if (objno == HADDR_UNDEF) { if (gen) { objno = ref_path_table_gen_fake(str); - HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno); + HDsnprintf(outstr, (size_t)outlen, "xid_" H5_PRINTF_HADDR_FMT, objno); return 0; } else { @@ -606,7 +608,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) else { if (gen) { objno = ref_path_table_gen_fake(str); - HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno); + HDsnprintf(outstr, (size_t)outlen, "xid_" H5_PRINTF_HADDR_FMT, objno); return 0; } else { @@ -615,7 +617,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) } } - HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno); + HDsnprintf(outstr, (size_t)outlen, "xid_" H5_PRINTF_HADDR_FMT, objno); return 0; } @@ -3557,7 +3559,10 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\""); for (i = 0; i < sz; i++) { - h5tools_str_append(&buffer, "%x ", *(unsigned int *)buf + (i * sizeof(unsigned int))); + unsigned long val = *(unsigned int *)buf + (i * sizeof(unsigned int)); + + H5_CHECK_OVERFLOW(val, unsigned long, unsigned); + h5tools_str_append(&buffer, "%x ", (unsigned)val); } h5tools_str_append(&buffer, "\""); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 100eba3..509cc87 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -3771,6 +3771,7 @@ getCompressionParameter(struct Input *in, FILE *strm) static int getExternalFilename(struct Input *in, FILE *strm) { + size_t temp_len; char temp[255]; const char *err1 = "Unable to get 'string' value.\n"; @@ -3779,8 +3780,10 @@ getExternalFilename(struct Input *in, FILE *strm) return (-1); } - in->externFilename = (char *)HDmalloc((size_t)(HDstrlen(temp) + 1) * sizeof(char)); - (void)HDstrncpy(in->externFilename, temp, HDstrlen(temp) + 1); + temp_len = HDstrlen(temp); + in->externFilename = (char *)HDmalloc((temp_len + 1) * sizeof(char)); + (void)HDstrcpy(in->externFilename, temp); + in->externFilename[temp_len] = '\0'; return (0); } diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c index c979e7a..b2dd765 100644 --- a/tools/src/h5perf/sio_perf.c +++ b/tools/src/h5perf/sio_perf.c @@ -277,7 +277,7 @@ run_test_loop(struct options *opts) } /* print size information */ - output_report("Transfer Buffer Size (bytes): %d\n", buf_bytes); + output_report("Transfer Buffer Size (bytes): %zu\n", buf_bytes); output_report("File Size(MB): %.2f\n", ((double)parms.num_bytes) / ONE_MB); print_indent(0); |