261 ch = str[i++]; |
261 ch = str[i++]; |
262 if(isspace(ch)) { |
262 if(isspace(ch)) { |
263 continue; |
263 continue; |
264 } |
264 } |
265 |
265 |
266 xmlSecAssert2(ch <= sizeof(xmlSecBnLookupTable), -1); |
266 xmlSecAssert2(ch <(sizeof(xmlSecBnLookupTable)/sizeof(xmlSecBnLookupTable[0])), -1); |
267 nn = xmlSecBnLookupTable[ch]; |
267 nn = xmlSecBnLookupTable[ch]; |
268 if((nn < 0) || ((xmlSecSize)nn > base)) { |
268 if((nn < 0) || ((xmlSecSize)nn > base)) { |
269 xmlSecError(XMLSEC_ERRORS_HERE, |
269 xmlSecError(XMLSEC_ERRORS_HERE, |
270 NULL, |
270 NULL, |
271 NULL, |
271 NULL, |
424 "len=%d", len); |
424 "len=%d", len); |
425 xmlSecBnFinalize(&bn2); |
425 xmlSecBnFinalize(&bn2); |
426 return (NULL); |
426 return (NULL); |
427 } |
427 } |
428 memset(res, 0, len + 1); |
428 memset(res, 0, len + 1); |
429 |
429 for(i = 0; (xmlSecBufferGetSize(&bn2) > 0) && (i < len); i++) |
430 for(i = 0; (xmlSecBufferGetSize(&bn2) > 0) && (i < len); i++) { |
430 { |
431 if(xmlSecBnDiv(&bn2, base, &nn) < 0) { |
431 if(xmlSecBnDiv(&bn2, base, &nn) < 0) |
|
432 { |
432 xmlSecError(XMLSEC_ERRORS_HERE, |
433 xmlSecError(XMLSEC_ERRORS_HERE, |
433 NULL, |
434 NULL, |
434 "xmlSecBnDiv", |
435 "xmlSecBnDiv", |
435 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
436 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
436 "base=%d", base); |
437 "base=%d", base); |
437 xmlFree(res); |
438 xmlFree(res); |
438 xmlSecBnFinalize(&bn2); |
439 xmlSecBnFinalize(&bn2); |
439 return (NULL); |
440 return (NULL); |
440 } |
441 } |
441 xmlSecAssert2((size_t)nn < sizeof(xmlSecBnRevLookupTable), NULL); |
442 if(nn >=(sizeof(xmlSecBnRevLookupTable)/sizeof(xmlSecBnRevLookupTable[0]))) |
|
443 { |
|
444 xmlFree(res); |
|
445 return (NULL); |
|
446 } |
442 res[i] = xmlSecBnRevLookupTable[nn]; |
447 res[i] = xmlSecBnRevLookupTable[nn]; |
443 } |
448 } |
444 xmlSecAssert2(i < len, NULL); |
449 if(i >=len) |
|
450 { |
|
451 xmlFree(res); |
|
452 return (NULL); |
|
453 } |
445 |
454 |
446 /* we might have '0' at the beggining, remove it but keep one zero */ |
455 /* we might have '0' at the beggining, remove it but keep one zero */ |
447 for(len = i; (len > 1) && (res[len - 1] == '0'); len--) |
456 for(len = i; (len > 1) && (res[len - 1] == '0'); len--) |
448 { |
457 { |
449 }; |
458 }; |