-/* $OpenBSD: a_strnid.c,v 1.21 2017/01/29 17:49:22 beck Exp $ */
+/* $OpenBSD: a_strnid.c,v 1.22 2021/12/11 22:34:36 schwarze Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
*/
*
*/
-#include <ctype.h>
#include <stdio.h>
#include <string.h>
const ASN1_STRING_TABLE * const *b);
-/* This is the global mask for the mbstring functions: this is use to
+/*
+ * This is the global mask for the mbstring functions: this is used to
* mask out certain types (such as BMPString and UTF8String) because
* certain software (e.g. Netscape) has problems with them.
*/
return global_mask;
}
-/* This function sets the default to various "flavours" of configuration.
+/*
+ * This function sets the default to various "flavours" of configuration
* based on an ASCII string. Currently this is:
* MASK:XXXX : a numerical mask value.
* nobmp : Don't use BMPStrings (just Printable, T61).
unsigned long mask;
char *end;
- if (!strncmp(p, "MASK:", 5)) {
- if (!p[5])
+ if (strncmp(p, "MASK:", 5) == 0) {
+ if (p[5] == '\0')
return 0;
mask = strtoul(p + 5, &end, 0);
- if (*end)
+ if (*end != '\0')
return 0;
- } else if (!strcmp(p, "nombstr"))
+ } else if (strcmp(p, "nombstr") == 0)
mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING));
- else if (!strcmp(p, "pkix"))
+ else if (strcmp(p, "pkix") == 0)
mask = ~((unsigned long)B_ASN1_T61STRING);
- else if (!strcmp(p, "utf8only"))
+ else if (strcmp(p, "utf8only") == 0)
mask = B_ASN1_UTF8STRING;
- else if (!strcmp(p, "default"))
+ else if (strcmp(p, "default") == 0)
mask = 0xFFFFFFFFL;
else
return 0;
return 1;
}
-/* The following function generates an ASN1_STRING based on limits in a table.
+/*
+ * The following function generates an ASN1_STRING based on limits in a table.
* Frequently the types and length of an ASN1_STRING are restricted by a
* corresponding OID. For example certificates and certificate requests.
*/
ASN1_STRING *str = NULL;
unsigned long mask;
int ret;
- if (!out)
+
+ if (out == NULL)
out = &str;
tbl = ASN1_STRING_TABLE_get(nid);
- if (tbl) {
+ if (tbl != NULL) {
mask = tbl->mask;
- if (!(tbl->flags & STABLE_NO_MASK))
+ if ((tbl->flags & STABLE_NO_MASK) == 0)
mask &= global_mask;
ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
tbl->minsize, tbl->maxsize);
return *out;
}
-/* Now the tables and helper functions for the string table:
+/*
+ * Now the tables and helper functions for the string table:
*/
/* size limits: this stuff is taken straight from RFC3280 */
STACK_OF(ASN1_STRING_TABLE) *tmp;
tmp = stable;
- if (!tmp)
+ if (tmp == NULL)
return;
stable = NULL;
sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);