Browse Source

add `LTC_OID_MAX_STRLEN`

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 3 years ago
parent
commit
b8cb13f998
3 changed files with 5 additions and 2 deletions
  1. 3 0
      src/headers/tomcrypt_private.h
  2. 1 1
      src/pk/asn1/oid/pk_oid_cmp.c
  3. 1 1
      src/pk/asn1/oid/pk_oid_str.c

+ 3 - 0
src/headers/tomcrypt_private.h

@@ -30,6 +30,8 @@ LTC_STATIC_ASSERT(correct_ltc_uintptr_size, sizeof(ltc_uintptr) == sizeof(void*)
  */
 #define LTC_ALIGN_BUF(buf, n) ((void*)((ltc_uintptr)&((unsigned char*)(buf))[n - 1] & (~(CONSTPTR(n) - CONSTPTR(1)))))
 
+#define LTC_OID_MAX_STRLEN 256
+
 /* `NULL` as defined by the standard is not guaranteed to be of a pointer
  * type. In order to make sure that in vararg API's a pointer type is used,
  * define our own version and use that one internally.
@@ -43,6 +45,7 @@ LTC_STATIC_ASSERT(correct_ltc_uintptr_size, sizeof(ltc_uintptr) == sizeof(void*)
  */
 
 enum ltc_oid_id {
+   LTC_OID_UNDEF,
    LTC_OID_RSA,
    LTC_OID_DSA,
    LTC_OID_EC,

+ 1 - 1
src/pk/asn1/oid/pk_oid_cmp.c

@@ -11,7 +11,7 @@
 int pk_oid_cmp_with_ulong(const char *o1, const unsigned long *o2, unsigned long o2size)
 {
    unsigned long i;
-   char tmp[256] = { 0 };
+   char tmp[LTC_OID_MAX_STRLEN] = { 0 };
    int err;
 
    if (o1 == NULL || o2 == NULL) return CRYPT_ERROR;

+ 1 - 1
src/pk/asn1/oid/pk_oid_str.c

@@ -46,7 +46,7 @@ int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID,
 {
    int i;
    unsigned long j, k;
-   char tmp[256] = { 0 };
+   char tmp[LTC_OID_MAX_STRLEN] = { 0 };
 
    LTC_ARGCHK(oid != NULL);
    LTC_ARGCHK(oidlen < INT_MAX);