From 599a63402dacf7e7d182233e067f9ac6e4f9c997 Mon Sep 17 00:00:00 2001 From: "nelsonb%netscape.com" Date: Sat, 22 May 2004 01:24:22 +0000 Subject: [PATCH] Fix crash when array member is used as variable. Bug 243655. r=relyea. --- security/nss/cmd/pk11util/pk11util.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/security/nss/cmd/pk11util/pk11util.c b/security/nss/cmd/pk11util/pk11util.c index 3688efd9d9e..9e4e7b379ec 100644 --- a/security/nss/cmd/pk11util/pk11util.c +++ b/security/nss/cmd/pk11util/pk11util.c @@ -385,7 +385,7 @@ makeArrayTarget(const char *vname, const Value *value, CK_ULONG index) char * target; CK_ULONG elementSize; - if (index > (CK_ULONG)value->arraySize) { + if (index >= (CK_ULONG)value->arraySize) { fprintf(stderr, "%s[%d]: index larger than array size (%d)\n", vname, index, value->arraySize); return NULL; @@ -1353,7 +1353,7 @@ putOutput(Value **ptr) type = ptr[i]->type; - ptr[i]->type &= ArgMask; + ptr[i]->type &= ~ArgOut; if (type == ArgNone) { break; } @@ -1931,22 +1931,19 @@ process(FILE *inFile,int user) bp = strip(buf); /* allow comments in scripts */ if (*bp == '#') { - if (user) { printf("pkcs11> "); fflush(stdout); } - continue; + goto done; } index = lookup(bp); if (index < 0) { - if (user) { printf("pkcs11> "); fflush(stdout); } - continue; + goto done; } arglist = parseArgs(index,bp); if (arglist == NULL) { - if (user) { printf("pkcs11> "); fflush(stdout); } - continue; + goto done; } error = do_func(index,arglist); @@ -1957,14 +1954,16 @@ process(FILE *inFile,int user) if (error) { ckrv = error; printf(">> Error : "); - printConst(error, ConstResult, 1); + printConst(error, ConstResult, 1); } putOutput(arglist); parseFree(arglist); - - if (user) { printf("pkcs11> "); fflush(stdout); } +done: + if (user) { + printf("pkcs11> "); fflush(stdout); + } } return ckrv; }