Datasets:
id int64 1 36.7k | label int64 0 1 | bug_url stringlengths 91 134 | bug_function stringlengths 13 72.7k | functions stringlengths 17 79.2k |
|---|---|---|---|---|
1 | 0 | https://github.com/libav/libav/blob/54bc15d5ebfd07fd468743ba29f709ea19e840b9/libswscale/output.c/#L1339 | static void
yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t **dest,... | ['static void\nyuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,\n const int16_t **lumSrc, int lumFilterSize,\n const int16_t *chrFilter, const int16_t **chrUSrc,\n const int16_t **chrVSrc, int chrFilterSize,\n const int16_t **alpSrc, uint8_t ... |
2 | 0 | https://github.com/openssl/openssl/blob/04485c5bc0dc7f49940e6d91b27cdcc7b83a8ab5/crypto/bn/bn_ctx.c/#L355 | static unsigned int BN_STACK_pop(BN_STACK *st)
{
return st->indexes[--(st->depth)];
} | ['int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)\n\t{\n\tBN_CTX *new_ctx = NULL;\n\tBIGNUM *tmp0, *tmp1;\n\tsize_t pow2 = 0;\n\tBIGNUM **heap = NULL;\n\tsize_t i;\n\tint ret = 0;\n\tif (num == 0)\n\t\treturn 1;\n\tif (ctx == NULL)\n\t\t{\n\t\tctx = new_ctx = BN_... |
3 | 0 | https://github.com/openssl/openssl/blob/fff684168c7923aa85e6b4381d71d933396e32b0/crypto/rsa/rsa_sp800_56b_gen.c/#L125 | int rsa_fips186_4_gen_prob_primes(RSA *rsa, BIGNUM *p1, BIGNUM *p2,
BIGNUM *Xpout, const BIGNUM *Xp,
const BIGNUM *Xp1, const BIGNUM *Xp2,
BIGNUM *q1, BIGNUM *q2, BIGNUM *Xqout,
const ... | ['int rsa_fips186_4_gen_prob_primes(RSA *rsa, BIGNUM *p1, BIGNUM *p2,\n BIGNUM *Xpout, const BIGNUM *Xp,\n const BIGNUM *Xp1, const BIGNUM *Xp2,\n BIGNUM *q1, BIGNUM *q2, BIGNUM *Xqout,\n ... |
4 | 0 | https://github.com/openssl/openssl/blob/d91f45688c2d0bfcc5b3b57fb20cc80b010eef0b/ssl/s3_enc.c/#L518 | int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
size_t len, size_t *secret_size)
{
static const unsigned char *salt[3] = {
#ifndef CHARSET_EBCDIC
(const unsigned char *)"A",
(const unsigned char *)"BB",
(const unsigned char *)"CCC... | ['int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,\n size_t len, size_t *secret_size)\n{\n static const unsigned char *salt[3] = {\n#ifndef CHARSET_EBCDIC\n (const unsigned char *)"A",\n (const unsigned char *)"BB",\n (const unsigned ch... |
5 | 0 | https://github.com/openssl/openssl/blob/c21869fb07ea02ffd46e817caeb47d85a85ee8ef/crypto/pem/pvkfmt.c/#L760 | static EVP_PKEY *do_PVK_body(const unsigned char **in,
unsigned int saltlen, unsigned int keylen,
pem_password_cb *cb, void *u)
{
EVP_PKEY *ret = NULL;
const unsigned char *p = *in;
unsigned int magic;
unsigned char *enctmp = NULL, *q;
EVP_CIPHER_CTX cctx;
EVP_CIPHER_CTX_init(&cctx);
if (saltlen)
{
char... | ['EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u)\n\t{\n\tunsigned char pvk_hdr[24], *buf = NULL;\n\tconst unsigned char *p;\n\tint buflen;\n\tEVP_PKEY *ret = NULL;\n\tunsigned int saltlen, keylen;\n\tif (BIO_read(in, pvk_hdr, 24) != 24)\n\t\t{\n\t\tPEMerr(PEM_F_B2I_PVK_BIO, PEM_R_PVK_DATA_TOO_SHORT);\n\t\... |
6 | 0 | https://github.com/libav/libav/blob/3ec394ea823c2a6e65a6abbdb2041ce1c66964f8/libavcodec/h264pred.c/#L359 | static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int stride){
LOAD_LEFT_EDGE
LOAD_DOWN_LEFT_EDGE
LOAD_TOP_EDGE
LOAD_TOP_RIGHT_EDGE
src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
src[2+0*stride]=
sr... | ['static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int stride){\n LOAD_LEFT_EDGE\n LOAD_DOWN_LEFT_EDGE\n LOAD_TOP_EDGE\n LOAD_TOP_RIGHT_EDGE\n src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;\n src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;\n src[2+0*stride... |
7 | 0 | https://github.com/libav/libav/blob/8d44cd2cd82e27e6b051fe0606dece3b0bec0bcd/libavformat/spdifenc.c/#L352 | static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
{
IEC61937Context *ctx = s->priv_data;
AACADTSHeaderInfo hdr;
GetBitContext gbc;
int ret;
init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
ret = ff_aac_parse_header(&gbc, &hdr);
if (ret < 0) {
av_log(s, AV_LOG_ER... | ['static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)\n{\n IEC61937Context *ctx = s->priv_data;\n AACADTSHeaderInfo hdr;\n GetBitContext gbc;\n int ret;\n init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);\n ret = ff_aac_parse_header(&gbc, &hdr);\n if (ret < 0) {\n av_log(s... |
8 | 1 | https://github.com/libav/libav/blob/63e8d9760f23a4edf81e9ae58c4f6d3baa6ff4dd/libavcodec/mpegaudiodec.c/#L681 | static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
int *dither_state, OUT_INT *samples, int incr)
{
register const MPA_INT *w, *w2, *p;
int j;
OUT_INT *samples2;
#if CONFIG_FLOAT
float sum, sum2;
#elif FRAC_BITS <= 15
int sum, sum2;
#else
int64_t s... | ['static void mpc_synth(MPCContext *c, int16_t *out)\n{\n int dither_state = 0;\n int i, ch;\n OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;\n for(ch = 0; ch < 2; ch++){\n samples_ptr = samples + ch;\n for(i = 0; i < SAMPLES_PER_BAND; i++) {\n ff_mpa_synth_filte... |
9 | 0 | https://github.com/libav/libav/blob/a92be9b856bd11b081041c43c25d442028fe9a63/libavcodec/smacker.c/#L610 | static int smka_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
SmackerAudioContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
GetBitContext gb;
HuffContext h[4] = { { 0 } };
VLC vlc[4] ... | ['static int smka_decode_frame(AVCodecContext *avctx, void *data,\n int *got_frame_ptr, AVPacket *avpkt)\n{\n SmackerAudioContext *s = avctx->priv_data;\n const uint8_t *buf = avpkt->data;\n int buf_size = avpkt->size;\n GetBitContext gb;\n HuffContext h[4] = { { 0 } };\n V... |
10 | 0 | https://github.com/openssl/openssl/blob/8da94770f0a049497b1a52ee469cca1f4a13b1a7/test/exptest.c/#L177 | static int test_exp_mod_zero()
{
BIGNUM *a = NULL, *p = NULL, *m = NULL;
BIGNUM *r = NULL;
BN_ULONG one_word = 1;
BN_CTX *ctx = BN_CTX_new();
int ret = 1, failed = 0;
m = BN_new();
if (!m)
goto err;
BN_one(m);
a = BN_new();
if (!a)
goto err;
BN_one(a);
p =... | ['static int test_exp_mod_zero()\n{\n BIGNUM *a = NULL, *p = NULL, *m = NULL;\n BIGNUM *r = NULL;\n BN_ULONG one_word = 1;\n BN_CTX *ctx = BN_CTX_new();\n int ret = 1, failed = 0;\n m = BN_new();\n if (!m)\n goto err;\n BN_one(m);\n a = BN_new();\n if (!a)\n goto err;\n BN... |
11 | 0 | https://github.com/libav/libav/blob/ab492ca2ab105aeb24d955f3f03756bdb3139ee1/libavcodec/mpeg12.c/#L198 | static inline int mpeg1_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->inter_matrix;
const int qscale = s->qscale;
{
... | ['static inline int mpeg1_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n)\n{\n int level, i, j, run;\n RLTable *rl = &ff_rl_mpeg1;\n uint8_t * const scantable = s->intra_scantable.permutated;\n const uint16_t *quant_matrix = s->inter_matrix;\n const int qscale = s->qscale;\n ... |
12 | 0 | https://github.com/openssl/openssl/blob/a21285b3636a8356f01027416b0cd43b016f58ca/crypto/bn/bn_lib.c/#L291 | BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
{
bn_check_top(b);
if (a == b)
return a;
if (bn_wexpand(a, b->top) == NULL)
return NULL;
if (b->top > 0)
memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
a->neg = b->neg;
a->top = b->top;
a->flags |= b->flags & BN_FLG_FIXED_TOP... | ['int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,\n const EVP_MD *evpmd, const unsigned char *seed_in,\n size_t seed_len, int idx, unsigned char *seed_out,\n int *counter_ret, unsigned long *h_ret,\n BN_GENCB *cb... |
13 | 0 | https://github.com/openssl/openssl/blob/2864df8f9d3264e19b49a246e272fb513f4c1be3/crypto/bn/bn_ctx.c/#L270 | static unsigned int BN_STACK_pop(BN_STACK *st)
{
return st->indexes[--(st->depth)];
} | ['static int field_tests_default(int n)\n{\n BN_CTX *ctx = NULL;\n EC_GROUP *group = NULL;\n int nid = curves[n].nid;\n int ret = 0;\n TEST_info("Testing curve %s\\n", OBJ_nid2sn(nid));\n if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))\n || !TEST_ptr(ctx = BN_CTX_new())\n || !grou... |
14 | 0 | https://github.com/nginx/nginx/blob/e5b2d3c6b2a132bbbbac0249566f0da7ff12bc39/src/http/ngx_http_core_module.c/#L2169 | ngx_int_t
ngx_http_internal_redirect(ngx_http_request_t *r,
ngx_str_t *uri, ngx_str_t *args)
{
ngx_http_core_srv_conf_t *cscf;
r->uri_changes--;
if (r->uri_changes == 0) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"rewrite or internal redirection cycle "
... | ['static ngx_int_t\nngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)\n{\n ngx_uint_t status;\n ngx_http_upstream_next_t *un;\n status = u->headers_in.status_n;\n for (un = ngx_http_upstream_next_errors; un->status; un++) {\n if (status != un->status) {\n ... |
15 | 0 | https://github.com/openssl/openssl/blob/1fac96e4d6484a517f2ebe99b72016726391723c/crypto/bn/bn_lib.c/#L447 | BIGNUM *bn_expand2(BIGNUM *b, int words)
{
BN_ULONG *A,*a;
const BN_ULONG *B;
int i;
bn_check_top(b);
if (words > b->max)
{
bn_check_top(b);
if (BN_get_flags(b,BN_FLG_STATIC_DATA))
{
BNerr(BN_F_BN_EXPAND2,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
return(NULL);
}
a=A=(BN_ULONG *)Malloc(sizeof(BN_ULON... | ['static int RSA_eay_private_decrypt(int flen, unsigned char *from,\n\t unsigned char *to, RSA *rsa, int padding)\n\t{\n\tBIGNUM f,ret;\n\tint j,num=0,r= -1;\n\tunsigned char *p;\n\tunsigned char *buf=NULL;\n\tBN_CTX *ctx=NULL;\n\tBN_init(&f);\n\tBN_init(&ret);\n\tctx=BN_CTX_new();\n\tif (ctx == NULL) goto err;\n\t... |
16 | 0 | https://github.com/openssl/openssl/blob/2864df8f9d3264e19b49a246e272fb513f4c1be3/crypto/bn/bn_ctx.c/#L270 | static unsigned int BN_STACK_pop(BN_STACK *st)
{
return st->indexes[--(st->depth)];
} | ['int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n const EC_POINT *b, BN_CTX *ctx)\n{\n BN_CTX *new_ctx = NULL;\n BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t;\n int ret = 0;\n if (EC_POINT_is_at_infinity(group, a)) {\n if (!EC_POINT_copy(r, b))\n ... |
17 | 0 | https://github.com/libav/libav/blob/fb0c9d41d685abb58575c5482ca33b8cd457c5ec/libavcodec/h264.c/#L218 | void ff_h264_draw_horiz_band(H264Context *h, int y, int height)
{
AVCodecContext *avctx = h->avctx;
Picture *cur = &h->cur_pic;
Picture *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0] : NULL;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int vshift = desc->log2_chro... | ['void ff_h264_draw_horiz_band(H264Context *h, int y, int height)\n{\n AVCodecContext *avctx = h->avctx;\n Picture *cur = &h->cur_pic;\n Picture *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0] : NULL;\n const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);\n int vshift = desc->l... |
18 | 0 | https://github.com/openssl/openssl/blob/d40a1b865fddc3d67f8c06ff1f1466fad331c8f7/crypto/asn1/asn1_lib.c/#L390 | int ASN1_STRING_set(ASN1_STRING *str, const void *_data, size_t len)
{
unsigned char *c;
const char *data=_data;
if (len < 0)
{
if (data == NULL)
return(0);
else
len=strlen(data);
}
if ((str->length < len) || (str->data == NULL))
{
c=str->data;
if (c == NULL)
str->data=OPENSSL_malloc(len+1);... | ['static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)\n\t{\n\tASN1_TYPE *atmp = NULL;\n\tCONF_VALUE vtmp;\n\tunsigned char *rdata;\n\tlong rdlen;\n\tint no_unused = 1;\n\tif (!(atmp = ASN1_TYPE_new()))\n\t\t{\n\t\tASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t\t}\n\tif (!... |
19 | 0 | https://github.com/libav/libav/blob/d9cf5f516974c64e01846ca685301014b38cf224/libavformat/mpegts.c/#L678 | static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
{
GetBitContext gb;
int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
int dts_flag = -1, cts_flag = -1;
int64_t dts = AV_N... | ['static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)\n{\n GetBitContext gb;\n int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;\n int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;\n int dts_flag = -1, cts_flag = -1;\n int64_t dt... |
20 | 0 | https://github.com/openssl/openssl/blob/2864df8f9d3264e19b49a246e272fb513f4c1be3/crypto/bn/bn_ctx.c/#L342 | static void BN_POOL_release(BN_POOL *p, unsigned int num)
{
unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
p->used -= num;
while (num--) {
bn_check_top(p->current->vals + offset);
if (offset == 0) {
offset = BN_CTX_POOL_SIZE - 1;
p->current = p->current->prev... | ['int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)\n{\n BIGNUM *b = NULL;\n int ret = 0;\n BN_CTX_start(ctx);\n if ((b = BN_CTX_get(ctx)) == NULL)\n goto err;\n do {\n if (!BN_priv_rand(b, BN_num_bits(p) - 1,\n BN_RAND_TOP_ANY, BN_RAND_B... |
21 | 0 | https://github.com/openssl/openssl/blob/924e5eda2c82d737cc5a1b9c37918aa6e34825da/apps/speed.c/#L2819 | static int do_multi(int multi)
{
int n;
int fd[2];
int *fds;
static char sep[]=":";
fds=malloc(multi*sizeof *fds);
for(n=0 ; n < multi ; ++n)
{
if (pipe(fd) == -1)
{
fprintf(stderr, "pipe failure\n");
exit(1);
}
fflush(stdout);
fflush(stderr);
if(fork())
{
close(fd[1]);
fds[n]=fd[0... | ['static int do_multi(int multi)\n\t{\n\tint n;\n\tint fd[2];\n\tint *fds;\n\tstatic char sep[]=":";\n\tfds=malloc(multi*sizeof *fds);\n\tfor(n=0 ; n < multi ; ++n)\n\t\t{\n\t\tif (pipe(fd) == -1)\n\t\t\t{\n\t\t\tfprintf(stderr, "pipe failure\\n");\n\t\t\texit(1);\n\t\t\t}\n\t\tfflush(stdout);\n\t\tfflush(stderr);\n\t\... |
22 | 0 | https://github.com/openssl/openssl/blob/1586365835e8eb950e804a4f1e62cff9563061bb/crypto/x509v3/v3_purp.c/#L121 | int X509_check_purpose(X509 *x, int id, int ca)
{
int idx;
const X509_PURPOSE *pt;
if(!(x->ex_flags & EXFLAG_SET)) {
CRYPTO_w_lock(CRYPTO_LOCK_X509);
x509v3_cache_extensions(x);
CRYPTO_w_unlock(CRYPTO_LOCK_X509);
}
if(id == -1) return 1;
idx = X509_PURPOSE_get_by_id(id);
if(idx == -1) return -1;
pt = X509... | ['int X509_check_purpose(X509 *x, int id, int ca)\n{\n\tint idx;\n\tconst X509_PURPOSE *pt;\n\tif(!(x->ex_flags & EXFLAG_SET)) {\n\t\tCRYPTO_w_lock(CRYPTO_LOCK_X509);\n\t\tx509v3_cache_extensions(x);\n\t\tCRYPTO_w_unlock(CRYPTO_LOCK_X509);\n\t}\n\tif(id == -1) return 1;\n\tidx = X509_PURPOSE_get_by_id(id);\n\tif(idx ==... |
23 | 0 | https://github.com/openssl/openssl/blob/1a50eedf2a1fbb1e0e009ad616d8be678e4c6340/crypto/bn/bn_ctx.c/#L276 | static unsigned int BN_STACK_pop(BN_STACK *st)
{
return st->indexes[--(st->depth)];
} | ['static int ecp_nistz256_points_mul(const EC_GROUP *group,\n EC_POINT *r,\n const BIGNUM *scalar,\n size_t num,\n const EC_POINT *points[],\n ... |
24 | 0 | https://github.com/libav/libav/blob/3ec394ea823c2a6e65a6abbdb2041ce1c66964f8/libavcodec/h264pred.c/#L357 | static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int stride){
LOAD_LEFT_EDGE
LOAD_DOWN_LEFT_EDGE
LOAD_TOP_EDGE
LOAD_TOP_RIGHT_EDGE
src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
src[2+0*stride]=
sr... | ['static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int stride){\n LOAD_LEFT_EDGE\n LOAD_DOWN_LEFT_EDGE\n LOAD_TOP_EDGE\n LOAD_TOP_RIGHT_EDGE\n src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;\n src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;\n src[2+0*stride... |
D2A: A Dataset Built for AI-Based Vulnerability Detection Methods Using Differential Analysis
This is an unofficial HuggingFace upload of the D2A dataset from "D2A: A Dataset Built for AI-Based Vulnerability Detection Methods Using Differential Analysis". "Test" splits have all labels as -1 as they are not provided.
Usage:
from datasets import load_dataset
# Use "code", "code_trace", "function", or "trace" to load the different variants.
dataset = load_dataset("claudios/D2A", "code")
D2A Leaderboard Data
This document describes D2A V1 Leaderboard data. You can download them from the Leaderboard section of the D2A Dataset page. To begin download directly you can click here.
Source files:
The files were created using the default security errors of datasets Libav, OpenSSL, Nginx, Httpd and Libtiff from D2A.
There are 4 directories corresponding to 4 tasks of the leaderboard. Each directory contains 3 csv files corresponding to the train (80%), dev (10%) and test (10%) split. The columns in the split files are identical except the test split which does not contain the label column.
Columns:
- id: A unique id for every example in a task.
- label: Values are 0 or 1.
- Value 0: No vulnerability/defect in the example.
- Value 1: Example contains some vulnerability/defect.
- trace: Bug trace or bug report generated by Infer static analyzer. Infer predictions contain a lot of False positives which is why even 0 label examples have a bug report.
- bug_function/code: Full source code of the function where the vulnerability originates.
- bug_url: URL of the file which contains the bug_function.
- functions: Full source code of all the functions in the bug trace, with the duplicates removed. This will include the function in bug_function.
Default Security Errors:
These are security errors enabled by default by Infer.
- BIABD_USE_AFTER_FREE
- BUFFER_OVERRUN_L1
- BUFFER_OVERRUN_L2
- BUFFER_OVERRUN_L3
- BUFFER_OVERRUN_R2
- BUFFER_OVERRUN_S2
- BUFFER_OVERRUN_T1
- INTEGER_OVERFLOW_L1
- INTEGER_OVERFLOW_L2
- INTEGER_OVERFLOW_R2
- MEMORY_LEAK
- NULL_DEREFERENCE
- RESOURCE_LEAK
- LAB_RESOURCE_LEAK
- UNINITIALIZED_VALUE
- USE_AFTER_DELETE
- USE_AFTER_FREE
- USE_AFTER_LIFETIME
Data Examples:
- Trace:
Offset: [4, +oo] (‚áê [0, +oo] + 4) Size: [0, 8388607] by call to `BN_mul`.
Showing all 12 steps of the trace
test/bntest.c:1798:10: Call
1796.
1797. /* Test that BN_mul never gives negative zero. */
1798. if (!BN_set_word(a, 1))
^
1799. goto err;
1800. BN_set_negative(a, 1);
crypto/bn/bn_lib.c:463:1: Parameter `*a->d`
461. }
462.
463. > int BN_set_word(BIGNUM *a, BN_ULONG w)
464. {
465. bn_check_top(a);
crypto/bn/bn_lib.c:466:9: Call
464. {
465. bn_check_top(a);
466. if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
^
467. return (0);
468. a->neg = 0;
crypto/bn/bn_lcl.h:676:1: Parameter `*a->d`
674. int bn_probable_prime_dh_coprime(BIGNUM *rnd, int bits, BN_CTX *ctx);
675.
676. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
677. {
678. if (bits > (INT_MAX - BN_BITS2 + 1))
test/bntest.c:1802:10: Call
1800. BN_set_negative(a, 1);
1801. BN_zero(b);
1802. if (!BN_mul(c, a, b, ctx))
^
1803. goto err;
1804. if (!BN_is_zero(c) || BN_is_negative(c)) {
crypto/bn/bn_mul.c:828:1: Parameter `*b->d`
826. #endif /* BN_RECURSION */
827.
828. > int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
829. {
830. int ret = 0;
crypto/bn/bn_mul.c:909:17: Call
907. if (bn_wexpand(rr, k * 4) == NULL)
908. goto err;
909. bn_mul_part_recursive(rr->d, a->d, b->d,
^
910. j, al - j, bl - j, t->d);
911. } else { /* al <= j || bl <= j */
crypto/bn/bn_mul.c:480:1: Parameter `*b`
478. */
479. /* tnX may not be negative but less than n */
480. > void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
481. int tna, int tnb, BN_ULONG *t)
482. {
crypto/bn/bn_mul.c:488:9: Call
486.
487. if (n < 8) {
488. bn_mul_normal(r, a, n + tna, b, n + tnb);
^
489. return;
490. }
crypto/bn/bn_mul.c:983:1: <Length trace>
981. }
982.
983. > void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
984. {
985. BN_ULONG *rr;
crypto/bn/bn_mul.c:983:1: Parameter `*b`
981. }
982.
983. > void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
984. {
985. BN_ULONG *rr;
crypto/bn/bn_mul.c:1018:50: Array access: Offset: [4, +oo] (‚áê [0, +oo] + 4) Size: [0, 8388607] by call to `BN_mul`
1016. if (--nb <= 0)
1017. return;
1018. rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]);
^
1019. rr += 4;
1020. r += 4;
"
- Bug URL:
https://github.com/openssl/openssl/blob/0282aeb690d63fab73a07191b63300a2fe30d212/crypto/bn/bn_mul.c/#L1018
- Bug Function:
"void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
{
BN_ULONG *rr;
if (na < nb) {
int itmp;
BN_ULONG *ltmp;
itmp = na;
na = nb;
nb = itmp;
ltmp = a;
a = b;
b = ltmp;
}
rr = &(r[na]);
if (nb <= 0) {
(void)bn_mul_words(r, a, na, 0);
return;
} else
rr[0] = bn_mul_words(r, a, na, b[0]);
for (;;) {
if (--nb <= 0)
return;
rr[1] = bn_mul_add_words(&(r[1]), a, na, b[1]);
if (--nb <= 0)
return;
rr[2] = bn_mul_add_words(&(r[2]), a, na, b[2]);
if (--nb <= 0)
return;
rr[3] = bn_mul_add_words(&(r[3]), a, na, b[3]);
if (--nb <= 0)
return;
rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]);
rr += 4;
r += 4;
b += 4;
}
}"
- Functions:
[
'static int test_negzero() {
BIGNUM * a = BN_new();
BIGNUM * b = BN_new();
BIGNUM * c = BN_new();
BIGNUM * d = BN_new();
BIGNUM * numerator = NULL, * denominator = NULL;
int consttime, st = 0;
if (a == NULL || b == NULL || c == NULL || d == NULL) goto err;
if (!BN_set_word(a, 1)) goto err;
BN_set_negative(a, 1);
BN_zero(b);
if (!BN_mul(c, a, b, ctx)) goto err;
if (!BN_is_zero(c) || BN_is_negative(c)) {
fprintf(stderr, "Multiplication test failed!");
goto err;
}
for (consttime = 0; consttime < 2; consttime++) {
numerator = BN_new();
denominator = BN_new();
if (numerator == NULL || denominator == NULL) goto err;
if (consttime) {
BN_set_flags(numerator, BN_FLG_CONSTTIME);
BN_set_flags(denominator, BN_FLG_CONSTTIME);
}
if (!BN_set_word(numerator, 1) || !BN_set_word(denominator, 2)) goto err;
BN_set_negative(numerator, 1);
if (!BN_div(a, b, numerator, denominator, ctx)) goto err;
if (!BN_is_zero(a) || BN_is_negative(a)) {
fprintf(stderr, "Incorrect quotient (consttime = %d).", consttime);
goto err;
}
if (!BN_set_word(denominator, 1)) goto err;
if (!BN_div(a, b, numerator, denominator, ctx)) goto err;
if (!BN_is_zero(b) || BN_is_negative(b)) {
fprintf(stderr, "Incorrect remainder (consttime = %d).", consttime);
goto err;
}
BN_free(numerator);
BN_free(denominator);
numerator = denominator = NULL;
}
BN_zero(a);
BN_set_negative(a, 1);
if (BN_is_negative(a)) {
fprintf(stderr, "BN_set_negative produced a negative zero.");
goto err;
}
st = 1;
err: BN_free(a);
BN_free(b);
BN_free(c);
BN_free(d);
BN_free(numerator);
BN_free(denominator);
return st;
}',
'int BN_set_word(BIGNUM * a, BN_ULONG w) {
bn_check_top(a);
if (bn_expand(a, (int) sizeof(BN_ULONG) * 8) == NULL) return (0);
a -> neg = 0;
a -> d[0] = w;
a -> top = (w ? 1 : 0);
bn_check_top(a);
return (1);
}',
'static ossl_inline BIGNUM * bn_expand(BIGNUM * a, int bits) {
if (bits > (INT_MAX - BN_BITS2 + 1)) return NULL;
if (((bits + BN_BITS2 - 1) / BN_BITS2) <= (a) -> dmax) return a;
return bn_expand2((a), (bits + BN_BITS2 - 1) / BN_BITS2);
}',
'int BN_mul(BIGNUM * r,
const BIGNUM * a,
const BIGNUM * b, BN_CTX * ctx) {
int ret = 0;
int top, al, bl;
BIGNUM * rr;
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) int i;
#endif #ifdef BN_RECURSION BIGNUM * t = NULL;
int j = 0, k;
#endif bn_check_top(a);
bn_check_top(b);
bn_check_top(r);
al = a -> top;
bl = b -> top;
if ((al == 0) || (bl == 0)) {
BN_zero(r);
return (1);
}
top = al + bl;
BN_CTX_start(ctx);
if ((r == a) || (r == b)) {
if ((rr = BN_CTX_get(ctx)) == NULL) goto err;
} else rr = r;
rr -> neg = a -> neg ^ b -> neg;
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) i = al - bl;
#endif #ifdef BN_MUL_COMBA
if (i == 0) {
#
if 0
if (al == 4) {
if (bn_wexpand(rr, 8) == NULL) goto err;
rr -> top = 8;
bn_mul_comba4(rr -> d, a -> d, b -> d);
goto end;
}
# endif
if (al == 8) {
if (bn_wexpand(rr, 16) == NULL) goto err;
rr -> top = 16;
bn_mul_comba8(rr -> d, a -> d, b -> d);
goto end;
}
}
#endif #ifdef BN_RECURSION
if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {
if (i >= -1 && i <= 1) {
if (i >= 0) {
j = BN_num_bits_word((BN_ULONG) al);
}
if (i == -1) {
j = BN_num_bits_word((BN_ULONG) bl);
}
j = 1 << (j - 1);
assert(j <= al || j <= bl);
k = j + j;
t = BN_CTX_get(ctx);
if (t == NULL) goto err;
if (al > j || bl > j) {
if (bn_wexpand(t, k * 4) == NULL) goto err;
if (bn_wexpand(rr, k * 4) == NULL) goto err;
bn_mul_part_recursive(rr -> d, a -> d, b -> d, j, al - j, bl - j, t -> d);
} else {
if (bn_wexpand(t, k * 2) == NULL) goto err;
if (bn_wexpand(rr, k * 2) == NULL) goto err;
bn_mul_recursive(rr -> d, a -> d, b -> d, j, al - j, bl - j, t -> d);
}
rr -> top = top;
goto end;
}
#
if 0
if (i == 1 && !BN_get_flags(b, BN_FLG_STATIC_DATA)) {
BIGNUM * tmp_bn = (BIGNUM * ) b;
if (bn_wexpand(tmp_bn, al) == NULL) goto err;
tmp_bn -> d[bl] = 0;
bl++;
i--;
} else if (i == -1 && !BN_get_flags(a, BN_FLG_STATIC_DATA)) {
BIGNUM * tmp_bn = (BIGNUM * ) a;
if (bn_wexpand(tmp_bn, bl) == NULL) goto err;
tmp_bn -> d[al] = 0;
al++;
i++;
}
if (i == 0) {
j = BN_num_bits_word((BN_ULONG) al);
j = 1 << (j - 1);
k = j + j;
t = BN_CTX_get(ctx);
if (al == j) {
if (bn_wexpand(t, k * 2) == NULL) goto err;
if (bn_wexpand(rr, k * 2) == NULL) goto err;
bn_mul_recursive(rr -> d, a -> d, b -> d, al, t -> d);
} else {
if (bn_wexpand(t, k * 4) == NULL) goto err;
if (bn_wexpand(rr, k * 4) == NULL) goto err;
bn_mul_part_recursive(rr -> d, a -> d, b -> d, al - j, j, t -> d);
}
rr -> top = top;
goto end;
}
# endif
}
#endif
if (bn_wexpand(rr, top) == NULL) goto err;
rr -> top = top;
bn_mul_normal(rr -> d, a -> d, al, b -> d, bl);
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) end: #endif bn_correct_top(rr);
if (r != rr && BN_copy(r, rr) == NULL) goto err;
ret = 1;
err: bn_check_top(r);
BN_CTX_end(ctx);
return (ret);
}',
'void bn_mul_part_recursive(BN_ULONG * r, BN_ULONG * a, BN_ULONG * b, int n, int tna, int tnb, BN_ULONG * t) {
int i, j, n2 = n * 2;
int c1, c2, neg;
BN_ULONG ln, lo, * p;
if (n < 8) {
bn_mul_normal(r, a, n + tna, b, n + tnb);
return;
}
c1 = bn_cmp_part_words(a, & (a[n]), tna, n - tna);
c2 = bn_cmp_part_words( & (b[n]), b, tnb, tnb - n);
neg = 0;
switch (c1 * 3 + c2) {
case -4:
bn_sub_part_words(t, & (a[n]), a, tna, tna - n);
bn_sub_part_words( & (t[n]), b, & (b[n]), tnb, n - tnb);
break;
case -3:
case -2:
bn_sub_part_words(t, & (a[n]), a, tna, tna - n);
bn_sub_part_words( & (t[n]), & (b[n]), b, tnb, tnb - n);
neg = 1;
break;
case -1:
case 0:
case 1:
case 2:
bn_sub_part_words(t, a, & (a[n]), tna, n - tna);
bn_sub_part_words( & (t[n]), b, & (b[n]), tnb, n - tnb);
neg = 1;
break;
case 3:
case 4:
bn_sub_part_words(t, a, & (a[n]), tna, n - tna);
bn_sub_part_words( & (t[n]), & (b[n]), b, tnb, tnb - n);
break;
}
#
if 0
if (n == 4) {
bn_mul_comba4( & (t[n2]), t, & (t[n]));
bn_mul_comba4(r, a, b);
bn_mul_normal( & (r[n2]), & (a[n]), tn, & (b[n]), tn);
memset( & r[n2 + tn * 2], 0, sizeof( * r) * (n2 - tn * 2));
} else # endif
if (n == 8) {
bn_mul_comba8( & (t[n2]), t, & (t[n]));
bn_mul_comba8(r, a, b);
bn_mul_normal( & (r[n2]), & (a[n]), tna, & (b[n]), tnb);
memset( & r[n2 + tna + tnb], 0, sizeof( * r) * (n2 - tna - tnb));
} else {
p = & (t[n2 * 2]);
bn_mul_recursive( & (t[n2]), t, & (t[n]), n, 0, 0, p);
bn_mul_recursive(r, a, b, n, 0, 0, p);
i = n / 2;
if (tna > tnb) j = tna - i;
else j = tnb - i;
if (j == 0) {
bn_mul_recursive( & (r[n2]), & (a[n]), & (b[n]), i, tna - i, tnb - i, p);
memset( & r[n2 + i * 2], 0, sizeof( * r) * (n2 - i * 2));
} else if (j > 0) {
bn_mul_part_recursive( & (r[n2]), & (a[n]), & (b[n]), i, tna - i, tnb - i, p);
memset( & (r[n2 + tna + tnb]), 0, sizeof(BN_ULONG) * (n2 - tna - tnb));
} else {
memset( & r[n2], 0, sizeof( * r) * n2);
if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL && tnb < BN_MUL_RECURSIVE_SIZE_NORMAL) {
bn_mul_normal( & (r[n2]), & (a[n]), tna, & (b[n]), tnb);
} else {
for (;;) {
i /= 2;
if (i < tna || i < tnb) {
bn_mul_part_recursive( & (r[n2]), & (a[n]), & (b[n]), i, tna - i, tnb - i, p);
break;
} else if (i == tna || i == tnb) {
bn_mul_recursive( & (r[n2]), & (a[n]), & (b[n]), i, tna - i, tnb - i, p);
break;
}
}
}
}
}
c1 = (int)(bn_add_words(t, r, & (r[n2]), n2));
if (neg) {
c1 -= (int)(bn_sub_words( & (t[n2]), t, & (t[n2]), n2));
} else {
c1 += (int)(bn_add_words( & (t[n2]), & (t[n2]), t, n2));
}
c1 += (int)(bn_add_words( & (r[n]), & (r[n]), & (t[n2]), n2));
if (c1) {
p = & (r[n + n2]);
lo = * p;
ln = (lo + c1) & BN_MASK2;* p = ln;
if (ln < (BN_ULONG) c1) {
do {
p++;
lo = * p;
ln = (lo + 1) & BN_MASK2;* p = ln;
} while (ln == 0);
}
}
}',
'void bn_mul_normal(BN_ULONG * r, BN_ULONG * a, int na, BN_ULONG * b, int nb) {
BN_ULONG * rr;
if (na < nb) {
int itmp;
BN_ULONG * ltmp;
itmp = na;
na = nb;
nb = itmp;
ltmp = a;
a = b;
b = ltmp;
}
rr = & (r[na]);
if (nb <= 0) {
(void) bn_mul_words(r, a, na, 0);
return;
} else rr[0] = bn_mul_words(r, a, na, b[0]);
for (;;) {
if (--nb <= 0) return;
rr[1] = bn_mul_add_words( & (r[1]), a, na, b[1]);
if (--nb <= 0) return;
rr[2] = bn_mul_add_words( & (r[2]), a, na, b[2]);
if (--nb <= 0) return;
rr[3] = bn_mul_add_words( & (r[3]), a, na, b[3]);
if (--nb <= 0) return;
rr[4] = bn_mul_add_words( & (r[4]), a, na, b[4]);
rr += 4;
r += 4;
b += 4;
}
}'
]
- Downloads last month
- 178