modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/compile/pr53886.c (about)

     1  /* PR target/53886  */
     2  typedef struct asn1_string_st ASN1_BIT_STRING;
     3  typedef struct bignum_st BIGNUM;
     4  typedef struct ec_group_st EC_GROUP;
     5  typedef struct ec_key_st EC_KEY;
     6  
     7  struct ec_key_st
     8  {
     9    EC_GROUP *group;
    10    BIGNUM *priv_key;
    11    unsigned int enc_flag;
    12  }
    13  X9_62_PENTANOMIAL;
    14  typedef struct ec_privatekey_st
    15  {
    16    ASN1_BIT_STRING *publicKey;
    17  }
    18  EC_PRIVATEKEY;
    19  
    20  extern EC_PRIVATEKEY* EC_PRIVATEKEY_new (void);
    21  extern void EC_PRIVATEKEY_free (EC_PRIVATEKEY*);
    22  extern unsigned char* CRYPTO_realloc (char*,int,const char*,int);
    23  
    24  int
    25  i2d_ECPrivateKey (EC_KEY * a, unsigned char **out)
    26  {
    27    int ret = 0, ok = 0;
    28    unsigned char *buffer = 0;
    29    unsigned buf_len = 0, tmp_len;
    30    EC_PRIVATEKEY *priv_key = 0;
    31    if (a == 0 || a->group == 0 || a->priv_key == 0)
    32      {
    33        ERR_put_error (16, (192), ((3 | 64)),
    34  		     "",
    35  		     1234);
    36        goto err;
    37      }
    38    if ((priv_key = EC_PRIVATEKEY_new ()) == 0)
    39      {
    40        ERR_put_error (16, (192), ((1 | 64)),
    41  		     "",
    42  		     1241);
    43        goto err;
    44      }
    45    if (!(a->enc_flag & 0x002))
    46      {
    47        if (priv_key->publicKey == 0)
    48  	{
    49  	  goto err;
    50  	}
    51        if (tmp_len > buf_len)
    52  	{
    53  	  unsigned char *tmp_buffer =
    54  	    CRYPTO_realloc ((char *) buffer, (int) tmp_len, "", 1293);
    55  	  buffer = tmp_buffer;
    56  	}
    57      }
    58    if ((ret = i2d_EC_PRIVATEKEY (priv_key, out)) == 0)
    59      {
    60      }
    61    ok = 1;
    62  err:
    63    if (buffer)
    64      CRYPTO_free (buffer);
    65    if (priv_key)
    66      EC_PRIVATEKEY_free (priv_key);
    67    return (ok ? ret : 0);
    68  }