snapshot-digestfail.patch

Check for EVP_DigestInit_ex failure and raise exception - Jared Jennings, 06/30/2011 12:19 AM

Download (1.02 KB)

View differences:

snapshot-digestfail/ext/openssl/ossl_digest.c 2011-06-29 08:57:46.000000000 -0500
68 68

  
69 69
    ret = ossl_digest_alloc(cDigest);
70 70
    GetDigest(ret, ctx);
71
    EVP_DigestInit_ex(ctx, md, NULL);
71
    if(!EVP_DigestInit_ex(ctx, md, NULL)) {
72
        rb_raise(rb_eArgError, "digest algorithm init failed");
73
    }
72 74

  
73 75
    return ret;
74 76
}
75 77

  
......
122 124
    if (!NIL_P(data)) StringValue(data);
123 125

  
124 126
    GetDigest(self, ctx);
125
    EVP_DigestInit_ex(ctx, md, NULL);
127
    if(!EVP_DigestInit_ex(ctx, md, NULL)) {
128
        rb_raise(rb_eArgError, "digest algorithm init failed");
129
    }
126 130

  
127 131
    if (!NIL_P(data)) return ossl_digest_update(self, data);
128 132
    return self;
129 133
}
......
159 163
    EVP_MD_CTX *ctx;
160 164

  
161 165
    GetDigest(self, ctx);
162
    EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL);
166
    if(!EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL)) {
167
        rb_raise(rb_eArgError, "digest algorithm init failed");
168
    }
163 169

  
164 170
    return self;
165 171
}