summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_util.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2005-08-17 19:21:36 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2005-08-17 19:21:36 (GMT)
commit7bbea1371134d93939225593a0a730db9b8e9c7b (patch)
tree1c193c9321b725be95a35f412f4209a3cb0b1da8 /tools/lib/h5diff_util.c
parent918c992dea6a975193f2f3fa1ced9f1f907c4aff (diff)
downloadhdf5-7bbea1371134d93939225593a0a730db9b8e9c7b.zip
hdf5-7bbea1371134d93939225593a0a730db9b8e9c7b.tar.gz
hdf5-7bbea1371134d93939225593a0a730db9b8e9c7b.tar.bz2
[svn-r11259] Purpose:
Bug fix Description: ph5diff had been hanging in Tflops. Found out that vsnprintf ph5diff uses was a local coded that did not limit printing according to the size argument. That resulted in buffer overflow and other problems. Solution: Added some sort of size checking in the home-grown vsnprintf and had ph5diff checked for error return of vsnprintf. Leon also revamped the ph5diff manager's way of handling communications with the workers. That eliminated all but the last case of hanging. Platforms tested: Tflops. Misc. update:
Diffstat (limited to 'tools/lib/h5diff_util.c')
-rw-r--r--tools/lib/h5diff_util.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 5370c1a..1fc710c 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -20,7 +20,7 @@
int g_nTasks = 1;
unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
char outBuff[OUTBUFF_SIZE];
-unsigned int outBuffOffset;
+int outBuffOffset;
FILE* overflow_file = NULL;
/*-------------------------------------------------------------------------
@@ -48,16 +48,27 @@ void parallel_print(const char* format, ...)
if(overflow_file == NULL) /*no overflow has occurred yet */
{
+#if 0
+printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
+#endif
bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
-
+#if 0
+printf("bytes_written=%ld\n", (long)bytes_written);
+#endif
va_end(ap);
va_start(ap, format);
+#if 0
+printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
+#endif
+
+ if ((bytes_written < 0) ||
#ifdef H5_VSNPRINTF_WORKS
- if(bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
+ (bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
#else
- if((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
+ ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
#endif
+ )
{
/* Terminate the outbuff at the end of the previous output */
outBuff[outBuffOffset] = '\0';