int hashed_len = 0;
der_pubkey_temp = der_pubkey = (unsigned char*)OPENSSL_malloc(der_len);
+ if (der_pubkey_temp == NULL || der_pubkey == NULL) {
+ _ERR("OPENSSL_malloc failed for der_pubkey");
+ free(cert_raw);
+ return NULL;
+ }
i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x509), (unsigned char **)&der_pubkey_temp);
size_t sig_len_loc = 0;
EVP_DigestSignFinal(mdctx, NULL, &sig_len_loc);
+
unsigned char *sig = (unsigned char *)OPENSSL_malloc(sizeof(unsigned char) * (sig_len_loc));
+ if (sig == NULL) {
+ _ERR("OPENSSL_malloc failed");
+ return NULL;
+ }
+
EVP_DigestSignFinal(mdctx, sig, &sig_len_loc);
*sig_len = sig_len_loc;
size_t sig_len_loc = 0;
EVP_DigestSignFinal(mdctx, NULL, &sig_len_loc);
+
unsigned char *sig = (unsigned char *)OPENSSL_malloc(sizeof(unsigned char) * (sig_len_loc));
+ if (sig == NULL) {
+ _ERR("OPENSSL_malloc failed");
+ return NULL;
+ }
+
EVP_DigestSignFinal(mdctx, sig, &sig_len_loc);
*sig_len = sig_len_loc;
ret = read(fd, buf, size - 1);
if (ret <= 0) {
_ERR("fd read error(%d)\n", fd);
- close(fd);
+
+ if (close(fd) == -1);
+ _ERR("fd close error");
+
return -1;
} else {
buf[ret] = 0;
}
- close(fd);
+ if (close(fd) == -1) {
+ _ERR("fd close error");
+ return -1;
+ }
return ret;
}