summaryrefslogtreecommitdiffstats
path: root/crypto/x509/v3_pci.c
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-06-21 08:55:50 +0200
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-11-17 15:48:34 +0100
commit2ff286c26c29b69b02ca99656d26d2f8cfd54682 (patch)
tree71a01c51c47d0dd9528ff14357615d71420ba5a1 /crypto/x509/v3_pci.c
parenta6838c8d52087f2b0494bbab8486e10944aff7f7 (diff)
Add and use HAS_PREFIX() and CHECK_AND_SKIP_PREFIX() for checking if string has literal prefix
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15847)
Diffstat (limited to 'crypto/x509/v3_pci.c')
-rw-r--r--crypto/x509/v3_pci.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/x509/v3_pci.c b/crypto/x509/v3_pci.c
index a931e01a9c..79fe76d042 100644
--- a/crypto/x509/v3_pci.c
+++ b/crypto/x509/v3_pci.c
@@ -112,6 +112,7 @@ static int process_pci_value(CONF_VALUE *val,
return 0;
}
} else if (strcmp(val->name, "policy") == 0) {
+ char *valp = val->value;
unsigned char *tmp_data = NULL;
long val_len;
@@ -124,9 +125,9 @@ static int process_pci_value(CONF_VALUE *val,
}
free_policy = 1;
}
- if (strncmp(val->value, "hex:", 4) == 0) {
+ if (CHECK_AND_SKIP_PREFIX(valp, "hex:")) {
unsigned char *tmp_data2 =
- OPENSSL_hexstr2buf(val->value + 4, &val_len);
+ OPENSSL_hexstr2buf(valp, &val_len);
if (!tmp_data2) {
X509V3_conf_err(val);
@@ -155,10 +156,10 @@ static int process_pci_value(CONF_VALUE *val,
goto err;
}
OPENSSL_free(tmp_data2);
- } else if (strncmp(val->value, "file:", 5) == 0) {
+ } else if (CHECK_AND_SKIP_PREFIX(valp, "file:")) {
unsigned char buf[2048];
int n;
- BIO *b = BIO_new_file(val->value + 5, "r");
+ BIO *b = BIO_new_file(valp, "r");
if (!b) {
ERR_raise(ERR_LIB_X509V3, ERR_R_BIO_LIB);
X509V3_conf_err(val);
@@ -194,8 +195,8 @@ static int process_pci_value(CONF_VALUE *val,
X509V3_conf_err(val);
goto err;
}
- } else if (strncmp(val->value, "text:", 5) == 0) {
- val_len = strlen(val->value + 5);
+ } else if (CHECK_AND_SKIP_PREFIX(valp, "text:")) {
+ val_len = strlen(valp);
tmp_data = OPENSSL_realloc((*policy)->data,
(*policy)->length + val_len + 1);
if (tmp_data) {