summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-04-05 13:13:26 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-04-06 12:58:33 +0200
commitdc48e882c309bed9589ba14c697802c6fa92c7e0 (patch)
treef7784059ce282dc172728a2689f1c4113def5817
parente0af1a2e108391430fdf154c1816258f4fb9b117 (diff)
downloadgnutls-dc48e882c309bed9589ba14c697802c6fa92c7e0.tar.gz
Mark with (void) the functions where the returned value is not checked intentionally
This allows static analysers to properly warn on unchecked return values. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--lib/x509/crl_write.c4
-rw-r--r--lib/x509/key_encode.c2
-rw-r--r--lib/x509/ocsp.c6
-rw-r--r--lib/x509/pkcs7.c26
-rw-r--r--lib/x509/x509_ext.c10
-rw-r--r--lib/x509/x509_write.c6
6 files changed, 32 insertions, 22 deletions
diff --git a/lib/x509/crl_write.c b/lib/x509/crl_write.c
index a775a136cb..6e5cfc9f28 100644
--- a/lib/x509/crl_write.c
+++ b/lib/x509/crl_write.c
@@ -317,11 +317,11 @@ static void disable_optional_stuff(gnutls_x509_crl_t crl)
t = _gnutls_x509_get_time(crl->crl, "tbsCertList.nextUpdate", 0);
if (t == (time_t)-1) {
- asn1_write_value(crl->crl, "tbsCertList.nextUpdate", NULL, 0);
+ (void)asn1_write_value(crl->crl, "tbsCertList.nextUpdate", NULL, 0);
}
if (crl->use_extensions == 0) {
- asn1_write_value(crl->crl, "tbsCertList.crlExtensions",
+ (void)asn1_write_value(crl->crl, "tbsCertList.crlExtensions",
NULL, 0);
}
diff --git a/lib/x509/key_encode.c b/lib/x509/key_encode.c
index 7df1026635..3277ca2476 100644
--- a/lib/x509/key_encode.c
+++ b/lib/x509/key_encode.c
@@ -658,7 +658,7 @@ _gnutls_asn1_encode_dsa(ASN1_TYPE * c2, gnutls_pk_params_st * params, unsigned c
goto cleanup;
}
} else {
- asn1_write_value(*c2, "seed", NULL, 0);
+ (void)asn1_write_value(*c2, "seed", NULL, 0);
}
if ((result =
diff --git a/lib/x509/ocsp.c b/lib/x509/ocsp.c
index 16a42fac13..d8a7b509be 100644
--- a/lib/x509/ocsp.c
+++ b/lib/x509/ocsp.c
@@ -328,13 +328,13 @@ int gnutls_ocsp_req_export(gnutls_ocsp_req_t req, gnutls_datum_t * data)
}
/* XXX remove when we support these fields */
- asn1_write_value(req->req, "tbsRequest.requestorName", NULL, 0);
- asn1_write_value(req->req, "optionalSignature", NULL, 0);
+ (void)asn1_write_value(req->req, "tbsRequest.requestorName", NULL, 0);
+ (void)asn1_write_value(req->req, "optionalSignature", NULL, 0);
/* prune extension field if we don't have any extension */
ret = gnutls_ocsp_req_get_extension(req, 0, NULL, NULL, NULL);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- asn1_write_value(req->req, "tbsRequest.requestExtensions",
+ (void)asn1_write_value(req->req, "tbsRequest.requestExtensions",
NULL, 0);
return _gnutls_x509_get_raw_field(req->req, "", data);
diff --git a/lib/x509/pkcs7.c b/lib/x509/pkcs7.c
index df17a4a33c..3bc5fb41de 100644
--- a/lib/x509/pkcs7.c
+++ b/lib/x509/pkcs7.c
@@ -1471,13 +1471,13 @@ static void disable_opt_fields(gnutls_pkcs7_t pkcs7)
/* disable the optional fields */
result = asn1_number_of_elements(pkcs7->signed_data, "crls", &count);
if (result != ASN1_SUCCESS || count == 0) {
- asn1_write_value(pkcs7->signed_data, "crls", NULL, 0);
+ (void)asn1_write_value(pkcs7->signed_data, "crls", NULL, 0);
}
result =
asn1_number_of_elements(pkcs7->signed_data, "certificates", &count);
if (result != ASN1_SUCCESS || count == 0) {
- asn1_write_value(pkcs7->signed_data, "certificates", NULL, 0);
+ (void)asn1_write_value(pkcs7->signed_data, "certificates", NULL, 0);
}
return;
@@ -2063,7 +2063,11 @@ static int write_signer_id(ASN1_TYPE c2, const char *root,
const uint8_t ver = 3;
snprintf(name, sizeof(name), "%s.version", root);
- asn1_write_value(c2, name, &ver, 1);
+ result = asn1_write_value(c2, name, &ver, 1);
+ if (result != ASN1_SUCCESS) {
+ gnutls_assert();
+ return _gnutls_asn2err(result);
+ }
snprintf(name, sizeof(name), "%s.sid", root);
result = asn1_write_value(c2, name, "subjectKeyIdentifier", 1);
@@ -2131,7 +2135,7 @@ static int add_attrs(ASN1_TYPE c2, const char *root, gnutls_pkcs7_attrs_t attrs,
if (attrs == NULL) {
/* if there are no other attributes delete that field */
if (already_set == 0)
- asn1_write_value(c2, root, NULL, 0);
+ (void)asn1_write_value(c2, root, NULL, 0);
} else {
while (p != NULL) {
result = asn1_write_value(c2, root, "NEW", 1);
@@ -2357,12 +2361,16 @@ int gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7,
}
if (!(flags & GNUTLS_PKCS7_EMBED_DATA)) {
- asn1_write_value(pkcs7->signed_data,
+ (void)asn1_write_value(pkcs7->signed_data,
"encapContentInfo.eContent", NULL, 0);
}
}
- asn1_write_value(pkcs7->signed_data, "version", &one, 1);
+ result = asn1_write_value(pkcs7->signed_data, "version", &one, 1);
+ if (result != ASN1_SUCCESS) {
+ ret = _gnutls_asn2err(result);
+ goto cleanup;
+ }
result =
asn1_write_value(pkcs7->signed_data,
@@ -2409,7 +2417,8 @@ int gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7,
ret = _gnutls_asn2err(result);
goto cleanup;
}
- asn1_write_value(pkcs7->signed_data,
+
+ (void)asn1_write_value(pkcs7->signed_data,
"digestAlgorithms.?LAST.parameters", NULL, 0);
/* append signer's info */
@@ -2438,7 +2447,8 @@ int gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7,
ret = _gnutls_asn2err(result);
goto cleanup;
}
- asn1_write_value(pkcs7->signed_data,
+
+ (void)asn1_write_value(pkcs7->signed_data,
"signerInfos.?LAST.digestAlgorithm.parameters", NULL,
0);
diff --git a/lib/x509/x509_ext.c b/lib/x509/x509_ext.c
index 94b068e3af..52473a025a 100644
--- a/lib/x509/x509_ext.c
+++ b/lib/x509/x509_ext.c
@@ -478,7 +478,7 @@ int gnutls_x509_ext_export_name_constraints(gnutls_x509_name_constraints_t nc,
}
if (nc->permitted == NULL) {
- asn1_write_value(c2, "permittedSubtrees", NULL, 0);
+ (void)asn1_write_value(c2, "permittedSubtrees", NULL, 0);
} else {
tmp = nc->permitted;
do {
@@ -525,7 +525,7 @@ int gnutls_x509_ext_export_name_constraints(gnutls_x509_name_constraints_t nc,
}
if (nc->excluded == NULL) {
- asn1_write_value(c2, "excludedSubtrees", NULL, 0);
+ (void)asn1_write_value(c2, "excludedSubtrees", NULL, 0);
} else {
tmp = nc->excluded;
do {
@@ -1022,7 +1022,7 @@ int gnutls_x509_ext_export_authority_key_id(gnutls_x509_aki_t aki,
goto cleanup;
}
} else {
- asn1_write_value(c2, "keyIdentifier", NULL, 0);
+ (void)asn1_write_value(c2, "keyIdentifier", NULL, 0);
}
if (aki->serial.data != NULL) {
@@ -1035,11 +1035,11 @@ int gnutls_x509_ext_export_authority_key_id(gnutls_x509_aki_t aki,
goto cleanup;
}
} else {
- asn1_write_value(c2, "authorityCertSerialNumber", NULL, 0);
+ (void)asn1_write_value(c2, "authorityCertSerialNumber", NULL, 0);
}
if (aki->cert_issuer.size == 0) {
- asn1_write_value(c2, "authorityCertIssuer", NULL, 0);
+ (void)asn1_write_value(c2, "authorityCertIssuer", NULL, 0);
} else {
for (i = 0; i < aki->cert_issuer.size; i++) {
ret =
diff --git a/lib/x509/x509_write.c b/lib/x509/x509_write.c
index 624ffe2a54..70e9cc0b1d 100644
--- a/lib/x509/x509_write.c
+++ b/lib/x509/x509_write.c
@@ -1391,16 +1391,16 @@ static void disable_optional_stuff(gnutls_x509_crt_t cert)
}
if (remove_issuer_unique_id)
- asn1_write_value(cert->cert, "tbsCertificate.issuerUniqueID", NULL,
+ (void)asn1_write_value(cert->cert, "tbsCertificate.issuerUniqueID", NULL,
0);
if (remove_subject_unique_id)
- asn1_write_value(cert->cert, "tbsCertificate.subjectUniqueID",
+ (void)asn1_write_value(cert->cert, "tbsCertificate.subjectUniqueID",
NULL, 0);
if (cert->use_extensions == 0) {
_gnutls_debug_log("Disabling X.509 extensions.\n");
- asn1_write_value(cert->cert, "tbsCertificate.extensions",
+ (void)asn1_write_value(cert->cert, "tbsCertificate.extensions",
NULL, 0);
}