]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Update asn1c for its generated code
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Fri, 30 Jun 2023 17:51:44 +0000 (11:51 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Fri, 30 Jun 2023 17:51:44 +0000 (11:51 -0600)
Inherits miscellaneous bugfixes.

Bumps asn1c from version 88ed3b5cf012918bc1084b606b0624c45e0d2191
to 9925dbbda86b436896108439ea3e0a31280a6065.

src/asn1/asn1c/INTEGER.c
src/asn1/asn1c/LICENSE
src/asn1/asn1c/NULL.c
src/asn1/asn1c/NULL.h
src/asn1/asn1c/ROAIPAddressFamily.c
src/asn1/asn1c/RouteOriginAttestation.c
src/asn1/asn1c/asn_internal.h

index 919ef7d174cba2a9674dae93b19bb02c416a7394..3ac4efc10251baeed881aababe0d8bb589a58df1 100644 (file)
@@ -1,5 +1,5 @@
-/*-
- * Copyright (c) 2003-2014 Lev Walkin <vlm@lionet.info>.
+/*
+ * Copyright (c) 2003-2019 Lev Walkin <vlm@lionet.info>.
  * All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
@@ -1037,64 +1037,71 @@ asn_ulong2INTEGER(INTEGER_t *st, unsigned long value) {
  */
 enum asn_strtox_result_e
 asn_strtoimax_lim(const char *str, const char **end, intmax_t *intp) {
-       int sign = 1;
-       intmax_t value;
+    int sign = 1;
+    intmax_t value;
 
-#define ASN1_INTMAX_MAX ((~(uintmax_t)0) >> 1)
-    const intmax_t upper_boundary = ASN1_INTMAX_MAX / 10;
-       intmax_t last_digit_max = ASN1_INTMAX_MAX % 10;
-#undef  ASN1_INTMAX_MAX
+    const intmax_t asn1_intmax_max = ((~(uintmax_t)0) >> 1);
+    const intmax_t upper_boundary = asn1_intmax_max / 10;
+    intmax_t last_digit_max = asn1_intmax_max % 10;
 
-       if(str >= *end) return ASN_STRTOX_ERROR_INVAL;
+    if(str >= *end) return ASN_STRTOX_ERROR_INVAL;
 
-       switch(*str) {
-       case '-':
-               last_digit_max++;
-               sign = -1;
-               /* FALL THROUGH */
-       case '+':
-               str++;
-               if(str >= *end) {
-                       *end = str;
-                       return ASN_STRTOX_EXPECT_MORE;
-               }
-       }
+    switch(*str) {
+    case '-':
+        last_digit_max++;
+        sign = -1;
+        /* FALL THROUGH */
+    case '+':
+        str++;
+        if(str >= *end) {
+            *end = str;
+            return ASN_STRTOX_EXPECT_MORE;
+        }
+    }
 
-       for(value = 0; str < (*end); str++) {
-               switch(*str) {
-               case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
-               case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: {
-                       int d = *str - '0';
-                       if(value < upper_boundary) {
-                               value = value * 10 + d;
-                       } else if(value == upper_boundary) {
-                               if(d <= last_digit_max) {
-                                       if(sign > 0) {
-                                               value = value * 10 + d;
-                                       } else {
-                                               sign = 1;
-                                               value = -value * 10 - d;
-                                       }
-                               } else {
-                                       *end = str;
-                                       return ASN_STRTOX_ERROR_RANGE;
-                               }
-                       } else {
-                               *end = str;
-                               return ASN_STRTOX_ERROR_RANGE;
-                       }
-                   }
-                   continue;
-               default:
-                   *end = str;
-                   *intp = sign * value;
-                   return ASN_STRTOX_EXTRA_DATA;
-               }
-       }
+    for(value = 0; str < (*end); str++) {
+        if(*str >= 0x30 && *str <= 0x39) {
+            int d = *str - '0';
+            if(value < upper_boundary) {
+                value = value * 10 + d;
+            } else if(value == upper_boundary) {
+                if(d <= last_digit_max) {
+                    if(sign > 0) {
+                        value = value * 10 + d;
+                    } else {
+                        sign = 1;
+                        value = -value * 10 - d;
+                    }
+                    str += 1;
+                    if(str < *end) {
+                        // If digits continue, we're guaranteed out of range.
+                        *end = str;
+                        if(*str >= 0x30 && *str <= 0x39) {
+                            return ASN_STRTOX_ERROR_RANGE;
+                        } else {
+                            *intp = sign * value;
+                            return ASN_STRTOX_EXTRA_DATA;
+                        }
+                    }
+                    break;
+                } else {
+                    *end = str;
+                    return ASN_STRTOX_ERROR_RANGE;
+                }
+            } else {
+                *end = str;
+                return ASN_STRTOX_ERROR_RANGE;
+            }
+        } else {
+            *end = str;
+            *intp = sign * value;
+            return ASN_STRTOX_EXTRA_DATA;
+        }
+    }
 
-       *end = str;
-       *intp = sign * value;
-       return ASN_STRTOX_OK;
+    *end = str;
+    *intp = sign * value;
+    return ASN_STRTOX_OK;
 }
 
 /*
@@ -1105,56 +1112,63 @@ asn_strtoimax_lim(const char *str, const char **end, intmax_t *intp) {
  */
 enum asn_strtox_result_e
 asn_strtoumax_lim(const char *str, const char **end, uintmax_t *uintp) {
-       uintmax_t value;
+    uintmax_t value;
 
-#define ASN1_UINTMAX_MAX ((~(uintmax_t)0))
-    const uintmax_t upper_boundary = ASN1_UINTMAX_MAX / 10;
-    uintmax_t last_digit_max = ASN1_UINTMAX_MAX % 10;
-#undef ASN1_UINTMAX_MAX
+    const uintmax_t asn1_uintmax_max = ((~(uintmax_t)0));
+    const uintmax_t upper_boundary = asn1_uintmax_max / 10;
+    uintmax_t last_digit_max = asn1_uintmax_max % 10;
 
     if(str >= *end) return ASN_STRTOX_ERROR_INVAL;
 
-       switch(*str) {
-       case '-':
+    switch(*str) {
+    case '-':
         return ASN_STRTOX_ERROR_INVAL;
-       case '+':
-               str++;
-               if(str >= *end) {
-                       *end = str;
-                       return ASN_STRTOX_EXPECT_MORE;
-               }
-       }
+    case '+':
+        str++;
+        if(str >= *end) {
+            *end = str;
+            return ASN_STRTOX_EXPECT_MORE;
+        }
+    }
 
-       for(value = 0; str < (*end); str++) {
-               switch(*str) {
-               case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
-               case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: {
-                       unsigned int d = *str - '0';
-                       if(value < upper_boundary) {
-                               value = value * 10 + d;
-                       } else if(value == upper_boundary) {
-                               if(d <= last_digit_max) {
+    for(value = 0; str < (*end); str++) {
+        if(*str >= 0x30 && *str <= 0x39) {
+            unsigned int d = *str - '0';
+            if(value < upper_boundary) {
+                value = value * 10 + d;
+            } else if(value == upper_boundary) {
+                if(d <= last_digit_max) {
                     value = value * 10 + d;
+                    str += 1;
+                    if(str < *end) {
+                        // If digits continue, we're guaranteed out of range.
+                        *end = str;
+                        if(*str >= 0x30 && *str <= 0x39) {
+                            return ASN_STRTOX_ERROR_RANGE;
+                        } else {
+                            *uintp = value;
+                            return ASN_STRTOX_EXTRA_DATA;
+                        }
+                    }
+                    break;
                 } else {
-                                       *end = str;
-                                       return ASN_STRTOX_ERROR_RANGE;
-                               }
-                       } else {
-                               *end = str;
-                               return ASN_STRTOX_ERROR_RANGE;
-                       }
-                   }
-                   continue;
-               default:
-                   *end = str;
-                   *uintp = value;
-                   return ASN_STRTOX_EXTRA_DATA;
-               }
-       }
+                    *end = str;
+                    return ASN_STRTOX_ERROR_RANGE;
+                }
+            } else {
+                *end = str;
+                return ASN_STRTOX_ERROR_RANGE;
+            }
+        } else {
+            *end = str;
+            *uintp = value;
+            return ASN_STRTOX_EXTRA_DATA;
+        }
+    }
 
-       *end = str;
-       *uintp = value;
-       return ASN_STRTOX_OK;
+    *end = str;
+    *uintp = value;
+    return ASN_STRTOX_OK;
 }
 
 enum asn_strtox_result_e
index 5e5b6ad0d0f455b2464a8032808efcdb0012f0e4..7075dbf13435f52e62a91cc5fe5142d975cceb63 100644 (file)
@@ -1,4 +1,4 @@
-Copyright (c) 2003-2013 Lev Walkin <vlm@lionet.info>
+Copyright (c) 2003-2017  Lev Walkin <vlm@lionet.info> and contributors.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
index 509972688bac16ff6fc1448cbf4cef761e599b13..80ed7231fc66089e3eb3db374dd07b9283e40a92 100644 (file)
@@ -5,7 +5,6 @@
 #include "asn1/asn1c/asn_internal.h"
 #include "asn1/asn1c/asn_codecs_prim.h"
 #include "asn1/asn1c/NULL.h"
-#include "asn1/asn1c/BOOLEAN.h"        /* Implemented in terms of BOOLEAN type */
 
 /*
  * NULL basic type description.
@@ -14,10 +13,10 @@ static const ber_tlv_tag_t asn_DEF_NULL_tags[] = {
        (ASN_TAG_CLASS_UNIVERSAL | (5 << 2))
 };
 asn_TYPE_operation_t asn_OP_NULL = {
-       BOOLEAN_free,
+       NULL_free,
        NULL_print,
        NULL_compare,
-       BOOLEAN_decode_ber,     /* Implemented in terms of BOOLEAN */
+       NULL_decode_ber,
        NULL_encode_der,        /* Special handling of DER encoding */
        NULL_decode_xer,
        NULL_encode_xer,
@@ -51,6 +50,65 @@ asn_TYPE_descriptor_t asn_DEF_NULL = {
        0       /* No specifics */
 };
 
+void
+NULL_free(const asn_TYPE_descriptor_t *td, void *ptr,
+          enum asn_struct_free_method method) {
+    if(td && ptr) {
+        switch(method) {
+        case ASFM_FREE_EVERYTHING:
+            FREEMEM(ptr);
+            break;
+        case ASFM_FREE_UNDERLYING:
+            break;
+        case ASFM_FREE_UNDERLYING_AND_RESET:
+            memset(ptr, 0, sizeof(NULL_t));
+            break;
+        }
+    }
+}
+
+/*
+ * Decode NULL type.
+ */
+asn_dec_rval_t
+NULL_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
+                const asn_TYPE_descriptor_t *td, void **bool_value,
+                const void *buf_ptr, size_t size, int tag_mode) {
+    NULL_t *st = (NULL_t *)*bool_value;
+    asn_dec_rval_t rval;
+    ber_tlv_len_t length;
+
+    if(st == NULL) {
+        st = (NULL_t *)(*bool_value = CALLOC(1, sizeof(*st)));
+        if(st == NULL) {
+            rval.code = RC_FAIL;
+            rval.consumed = 0;
+            return rval;
+        }
+    }
+
+    ASN_DEBUG("Decoding %s as NULL (tm=%d)", td->name, tag_mode);
+
+    /*
+     * Check tags.
+     */
+    rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
+                          &length, 0);
+    if(rval.code != RC_OK) {
+        return rval;
+    }
+
+    // X.690-201508, #8.8.2, length shall be zero.
+    if(length != 0) {
+        ASN_DEBUG("Decoding %s as NULL failed: too much data", td->name);
+        rval.code = RC_FAIL;
+        rval.consumed = 0;
+        return rval;
+    }
+
+    return rval;
+}
+
 asn_enc_rval_t
 NULL_encode_der(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode,
                 ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
index 1c3f787d15bd1141381b28f368e5c0c44a3ea9f3..6153e2d4c3169bac6d293e5055305cd0db18c15c 100644 (file)
@@ -6,23 +6,24 @@
 #define        ASN_TYPE_NULL_H
 
 #include "asn1/asn1c/asn_application.h"
-#include "asn1/asn1c/BOOLEAN.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /*
- * The value of the NULL type is meaningless: see BOOLEAN if you want to
- * carry true/false semantics.
+ * The value of the NULL type is meaningless.
+ * Use the BOOLEAN type if you need to carry true/false semantics.
  */
 typedef int NULL_t;
 
 extern asn_TYPE_descriptor_t asn_DEF_NULL;
 extern asn_TYPE_operation_t asn_OP_NULL;
 
+asn_struct_free_f NULL_free;
 asn_struct_print_f NULL_print;
 asn_struct_compare_f NULL_compare;
+ber_type_decoder_f NULL_decode_ber;
 der_type_encoder_f NULL_encode_der;
 xer_type_decoder_f NULL_decode_xer;
 xer_type_encoder_f NULL_encode_xer;
@@ -32,8 +33,6 @@ per_type_decoder_f NULL_decode_uper;
 per_type_encoder_f NULL_encode_uper;
 asn_random_fill_f  NULL_random_fill;
 
-#define NULL_free      BOOLEAN_free
-#define NULL_decode_ber        BOOLEAN_decode_ber
 #define NULL_constraint        asn_generic_no_constraint
 
 #ifdef __cplusplus
index d5d7c9be15734f8c26cf3f0cf9c9d97cc4117c21..cb3c0963ab3aada6a558184d27a70d5451b2b7df 100644 (file)
@@ -50,7 +50,7 @@ memb_addresses_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
        
        if((size >= 1)) {
                /* Perform validation of the inner elements */
-               return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
+               return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);
        } else {
                ASN__CTFAIL(app_key, td, sptr,
                        "%s: constraint failed (%s:%d)",
index 0fb07dea90287d35c1b6009fb42dff14764ace36..da26f1523e44fe40bd3f127a8409e18023eb5d62 100644 (file)
@@ -24,7 +24,7 @@ memb_ipAddrBlocks_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr
        
        if((size >= 1)) {
                /* Perform validation of the inner elements */
-               return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
+               return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);
        } else {
                ASN__CTFAIL(app_key, td, sptr,
                        "%s: constraint failed (%s:%d)",
index 2736083143091cbacce4dad56c4185f7a91b3aac..4e72d62f30addb09bc9fd92c354ff1233d321e69 100644 (file)
@@ -7,8 +7,9 @@
  */
 #ifndef        ASN_INTERNAL_H
 #define        ASN_INTERNAL_H
+#ifndef __EXTENSIONS__
 #define __EXTENSIONS__          /* for Sun */
-
+#endif
 #include "asn_application.h"   /* Application-visible API */
 
 #ifndef        __NO_ASSERT_H__         /* Include assert.h only for internal use. */