diff --git a/mozilla/modules/libreg/src/reg.c b/mozilla/modules/libreg/src/reg.c index d6df1c02a13..d7bd43c3d11 100644 --- a/mozilla/modules/libreg/src/reg.c +++ b/mozilla/modules/libreg/src/reg.c @@ -925,7 +925,7 @@ static REGERR nr_ReadName(REGFILE *reg, REGDESC *desc, uint32 buflen, char *buf) XP_ASSERT(buflen > 0); XP_ASSERT(buf); - if ( desc->namelen > buflen ) + if ( buflen == 0 || desc->namelen > buflen ) return REGERR_BUFTOOSMALL; err = nr_ReadFile(reg->fh, desc->name, desc->namelen, buf); @@ -1292,6 +1292,8 @@ static REGERR nr_NextName(const char *pPath, char *buf, uint32 bufsize, const ch /* initialization and validation */ XP_ASSERT(buf); + if ( bufsize == 0 ) + return REGERR_BUFTOOSMALL; *newPath = NULL; *buf = '\0'; @@ -1314,9 +1316,8 @@ static REGERR nr_NextName(const char *pPath, char *buf, uint32 bufsize, const ch /* copy first path segment into return buf */ while ( *pPath != '\0' && *pPath != PATHDEL ) { - if ( len == bufsize ) { - err = REGERR_NAMETOOLONG; - break; + if ( len == bufsize-1 ) { + return REGERR_NAMETOOLONG; } if ( *pPath < ' ' && *pPath > 0 ) return REGERR_BADNAME; @@ -1391,7 +1392,7 @@ static REGERR nr_ReplaceName(REGFILE *reg, REGOFF node, char *path, uint32 bufsi XP_ASSERT(path); len = XP_STRLEN(path); - if ( len > bufsize ) + if ( len >= bufsize ) return REGERR_PARAM; if ( len > 0 ) { @@ -3439,7 +3440,7 @@ VR_INTERFACE(REGERR) NR_RegEnumSubkeys( HREG hReg, RKEY key, REGENUM *state, if ( err != REGERR_OK ) return err; - if ( key == 0 || state == NULL || buffer == NULL ) + if ( key == 0 || state == NULL || buffer == NULL || bufsize == 0 ) return REGERR_PARAM; reg = ((REGHANDLE*)hReg)->pReg; @@ -3654,7 +3655,7 @@ VR_INTERFACE(REGERR) NR_RegEnumEntries( HREG hReg, RKEY key, REGENUM *state, if ( err != REGERR_OK ) return err; - if ( key == 0 || state == NULL || buffer == NULL ) + if ( key == 0 || state == NULL || buffer == NULL || bufsize == 0 ) return REGERR_PARAM; reg = ((REGHANDLE*)hReg)->pReg;