From dd3243e79f63d9851093b0844955afec04bf1d3e Mon Sep 17 00:00:00 2001 From: jasonw Date: Fri, 6 Aug 2010 15:47:47 +0000 Subject: [PATCH] - update CHANGELOG - added debug messages and a check for glibc return codes from vsnprintf to MUSNPrintF() git-svn-id: svn://opensvn.adaptivecomputing.com/maui/trunk@144 3f5042e3-fb1d-0410-be18-d6ca2573e517 --- CHANGELOG | 8 ++++++++ src/moab/MUtil.c | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e17fedf..ef642ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,14 @@ Maui 3.3.1 - Added build system changes to support Cygwin (Yauheni Charniauski, UIIP Minsk) - Added the --with-cygrunsrv configure option for start maui as Windows service (doesn't use a background daemon). Cygwin utility cygrunsrv.exe goes it into background independently (Igor Ilyenko, UIIP Minsk) + - changed all remaining mallocs to callocs which zeros memory on allocation. Fixes a crash due + to the way some whiel loops in MResAdjustDRes() expect things to be. (Jason Williams) + - Added proper memory allocation checks to accompany the callocs in MRes.c to avoid + missing memory errors. (Jason Williams) + - Added debug print messages to MUSNPrintF() and added a proper check of the return + code to vsnprintf to be in accordance with glibc >=2.1, if installed. (Jason Williams) + - Changed top-level Makefile BUILDROOT assignment to allow RPM builds (Jason Williams) + - Minor changes to fix a few valgrind errors about uninitialized values (Jason Williams) Maui 3.3 - Fixed configure script. Was putting RMCFG[name] TYPE=PBS@RMNMHOST@. diff --git a/src/moab/MUtil.c b/src/moab/MUtil.c index c2f729f..8675502 100644 --- a/src/moab/MUtil.c +++ b/src/moab/MUtil.c @@ -5089,7 +5089,7 @@ int MUSNPrintF( { int len; - + const char *FName = "MUSNPrintF"; va_list Args; if ((BPtr == NULL) || @@ -5097,6 +5097,8 @@ int MUSNPrintF( (Format == NULL) || (*BSpace <= 0)) { + DBG(4,fCORE) DPrint("ALERT: Memory Error in %s\n", + FName); return(FAILURE); } @@ -5108,9 +5110,23 @@ int MUSNPrintF( if (len <= 0) { + DBG(4,fCORE) DPrint("ALERT: vsnprintf Error in %s\n", + FName); return(FAILURE); } +#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 + /* XXX: The following is true for glibc > 2.1 */ + + /* if vsnprintf returns the same value as size or greater */ + /* then the output is truncated. see man vsnprintf. */ + if (len == *BSpace || len > *BSpace) { + DBG(1,fCORE) DPrint("ALERT: Possible vsnprintf truncation in %s\n", + FName); + return(FAILURE); + } +#endif + *BPtr += len; *BSpace -= len;