Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/ecdsa_impl.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | static int secp256k1_der_read_len(const unsigned char **sigp, const unsigned char *sigend) { | ||||
} | } | ||||
if ((size_t)lenleft > sizeof(size_t)) { | if ((size_t)lenleft > sizeof(size_t)) { | ||||
/* The resulting length would exceed the range of a size_t, so | /* The resulting length would exceed the range of a size_t, so | ||||
* certainly longer than the passed array size. | * certainly longer than the passed array size. | ||||
*/ | */ | ||||
return -1; | return -1; | ||||
} | } | ||||
while (lenleft > 0) { | while (lenleft > 0) { | ||||
if ((ret >> ((sizeof(size_t) - 1) * 8)) != 0) { | |||||
} | |||||
ret = (ret << 8) | **sigp; | ret = (ret << 8) | **sigp; | ||||
if (ret + lenleft > (size_t)(sigend - *sigp)) { | if (ret + lenleft > (size_t)(sigend - *sigp)) { | ||||
/* Result exceeds the length of the passed array. */ | /* Result exceeds the length of the passed array. */ | ||||
return -1; | return -1; | ||||
} | } | ||||
(*sigp)++; | (*sigp)++; | ||||
lenleft--; | lenleft--; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |