summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2005-11-16 18:09:38 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2005-11-16 18:09:38 (GMT)
commit7fbe30d5abcaf3218a7cea93137fe1f76566484a (patch)
tree3f37b922733208588aa27677824a4ab434bdbdf1 /src
parent671187fd2b53c916f444e849a2fd57bac06552f8 (diff)
downloadhdf5-7fbe30d5abcaf3218a7cea93137fe1f76566484a.zip
hdf5-7fbe30d5abcaf3218a7cea93137fe1f76566484a.tar.gz
hdf5-7fbe30d5abcaf3218a7cea93137fe1f76566484a.tar.bz2
[svn-r11735] Purpose:
Cleanup. Description: Removed the home-made version of snprintf and vsnprintf since they do not actually enforce the size parameter correctly and could corrupt memory or as a security hole. This block of code has been turned off since Aug 11, 2005 for all platforms except Tflops. No one has reported any problem since--sort of empirical evidence that all platforms except Tflops support both functions. Tflops has retired in September. So, no need to keep this block of code. Also, fixed the HDxxx macro to call the corresponding xxx function. Platforms tested: Tested in heping, both serial and parallel.
Diffstat (limited to 'src')
-rw-r--r--src/H5.c101
-rw-r--r--src/H5private.h19
2 files changed, 2 insertions, 118 deletions
diff --git a/src/H5.c b/src/H5.c
index 08feddc..86322a2 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -733,107 +733,6 @@ H5close(void)
}
-/* disable the code of HDsnprintf and HDvsnprintf below to see if they
- * are still needed by what platforms. AKC 2005/8/11.
- * Turn it on for the Tflops (__PUMAGON__) machine. AKC 2005/8/12.
- * The SN_SIZ_MIN is an attempt to require the minimum amount of space needed,
- * hoping vsnprintf/snprintf do not print larger than it per request.
- */
-#ifdef __PUMAGON__
-#define H5_SN_SIZE_MIN 256
-#ifndef H5_HAVE_SNPRINTF
-/*-------------------------------------------------------------------------
- * Function: HDsnprintf
- *
- * Purpose: Writes output to the string BUF under control of the format
- * FMT that specifies how subsequent arguments are converted for
- * output. It is similar to sprintf except that SIZE specifies
- * the maximum number of characters to produce. The trailing
- * null character is counted towards this limit, so you should
- * allocated at least SIZE characters for the string BUF.
- *
- * Note: This function is for compatibility on systems that don't have
- * snprintf(3). It doesn't actually check for overflow like the
- * real snprintf() would.
- *
- * Return: Success: Number of characters stored, not including
- * the terminating null. If this value equals
- * SIZE then there was not enough space in BUF
- * for all the output.
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Tuesday, November 24, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-int
-HDsnprintf(char *buf, size_t UNUSED size, const char *fmt, ...)
-{
- int n;
- va_list ap;
-
- if (size < H5_SN_SIZE_MIN) /* Not safe to call vsprintf */
- return -1;
- va_start(ap, fmt);
- n = HDvsprintf(buf, fmt, ap);
- va_end(ap);
- if (n >= size){
- /* buffer overflow has occurred. Attempt to report an error. */
- return -1;
- }
- return n;
-}
-#endif /* H5_HAVE_SNPRINTF */
-
-
-#ifndef H5_HAVE_VSNPRINTF
-/*-------------------------------------------------------------------------
- * Function: HDvsnprintf
- *
- * Purpose: The same as HDsnprintf() except the variable arguments are
- * passed as a va_list.
- *
- * Note: This function is for compatibility on systems that don't have
- * vsnprintf(3). It doesn't actually check for overflow like the
- * real vsnprintf() would.
- *
- * Return: Success: Number of characters stored, not including
- * the terminating null. If this value equals
- * SIZE then there was not enough space in BUF
- * for all the output.
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Monday, April 26, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-int
-HDvsnprintf(char *buf, size_t UNUSED size, const char *fmt, va_list ap)
-{
- int n;
- if (size < H5_SN_SIZE_MIN) /* Not safe to call vsprintf */
- return -1;
- n = HDvsprintf(buf, fmt, ap);
- if (n >= size){
- /* buffer overflow has occurred. Attempt to report an error. */
- return -1;
- }
- return n;
-}
-#endif /* H5_HAVE_VSNPRINTF */
-#endif /* __PUMAGON__ */
-
-
/*-------------------------------------------------------------------------
* Function: HDfprintf
*
diff --git a/src/H5private.h b/src/H5private.h
index 21e2d43..b86a419 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -801,12 +801,10 @@ typedef off_t h5_stat_size_t;
#define HDsin(X) sin(X)
#define HDsinh(X) sinh(X)
#define HDsleep(N) sleep(N)
-#ifdef H5_HAVE_SNPRINTF
#ifdef WIN32
-#define HDsnprintf _snprintf /*varargs*/
+#define HDsnprintf _snprintf /*varargs*/
#else
-# define HDsnprintf snprintf /*varargs*/
-#endif
+#define HDsnprintf snprintf /*varargs*/
#endif
/* sprintf() variable arguments */
#define HDsqrt(X) sqrt(X)
@@ -887,13 +885,11 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base);
#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
#define HDvprintf(FMT,A) vprintf(FMT,A)
#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
-#ifdef H5_HAVE_VSNPRINTF
#ifdef WIN32
# define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A)
#else
# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A)
#endif
-#endif
#define HDwait(W) wait(W)
#define HDwaitpid(P,W,O) waitpid(P,W,O)
#define HDwcstombs(S,P,Z) wcstombs(S,P,Z)
@@ -925,17 +921,6 @@ extern char *strdup(const char *s);
#endif /* WIN32 */
-/* Define our own HDsnprintf only for TFLOPS. */
-#ifdef __PUMAGON__
-#ifndef H5_HAVE_SNPRINTF
-H5_DLL int HDsnprintf(char *buf, size_t size, const char *fmt, ...);
-#endif
-
-#ifndef H5_HAVE_VSNPRINTF
-H5_DLL int HDvsnprintf(char *buf, size_t size, const char *fmt, va_list ap);
-#endif
-#endif
-
/*
* These macros check whether debugging has been requested for a certain
* package at run-time. Code for debugging is conditionally compiled by