bits = GET_16BIT(buf);
/* Compute the number of binary bytes that follow. */
bytes = (bits + 7) / 8;
- bin = xmalloc(bytes);
- buffer_get(buffer, bin, bytes);
+ if (buffer_len(buffer) < bytes)
+ fatal("buffer_get_bignum: input buffer too small");
+ bin = buffer_ptr(buffer);
BN_bin2bn(bin, bytes, value);
- xfree(bin);
+ buffer_consume(buffer, bytes);
return 2 + bytes;
}