… | |
… | |
260 | if (expect_false (c == 0x80)) |
260 | if (expect_false (c == 0x80)) |
261 | error ("illegal BER padding (X.690 8.1.2.4.2, 8.19.2)"); |
261 | error ("illegal BER padding (X.690 8.1.2.4.2, 8.19.2)"); |
262 | |
262 | |
263 | for (;;) |
263 | for (;;) |
264 | { |
264 | { |
|
|
265 | if (expect_false (res >> UVSIZE * 8 - 7)) |
|
|
266 | error ("BER variable integer overflow"); |
|
|
267 | |
265 | res = (res << 7) | (c & 0x7f); |
268 | res = (res << 7) | (c & 0x7f); |
266 | |
269 | |
267 | if (!(c & 0x80)) |
270 | if (!(c & 0x80)) |
268 | return res; |
271 | return res; |
269 | |
272 | |
… | |
… | |
326 | |
329 | |
327 | int negative = data [0] & 0x80; |
330 | int negative = data [0] & 0x80; |
328 | |
331 | |
329 | UV val = negative ? -1 : 0; // copy signbit to all bits |
332 | UV val = negative ? -1 : 0; // copy signbit to all bits |
330 | |
333 | |
|
|
334 | if (len > UVSIZE + (!negative && !*data)) |
|
|
335 | //printf ("len %d > %d + (!%d && !%d) = %d\n", len, UVSIZE, negative, *data, UVSIZE + (!negative && !*data));//D |
|
|
336 | error ("INTEGER overflow"); |
|
|
337 | |
331 | do |
338 | do |
332 | val = (val << 8) | *data++; |
339 | val = (val << 8) | *data++; |
333 | while (--len); |
340 | while (--len); |
334 | |
341 | |
335 | // the cast to IV relies on implementation-defined behaviour (two's complement cast) |
342 | // the cast to IV relies on implementation-defined behaviour (two's complement cast) |
… | |
… | |
389 | } |
396 | } |
390 | |
397 | |
391 | U8 *end = cur + len; |
398 | U8 *end = cur + len; |
392 | UV w = get_w (); |
399 | UV w = get_w (); |
393 | |
400 | |
394 | static char oid[MAX_OID_STRLEN]; // static, becaueds too large for stack |
401 | static char oid[MAX_OID_STRLEN]; // static, because too large for stack |
395 | char *app = oid; |
402 | char *app = oid; |
396 | |
403 | |
397 | if (relative) |
404 | if (relative) |
398 | app = write_uv (app, w); |
405 | app = write_uv (app, w); |
399 | else if (w < 2 * 40) |
406 | else if (w < 2 * 40) |