| From: D. Hugh Redelmeier <[email protected]>

| OID 89 is terminal but has no name
| 
|       I don't know what OID names are used for, but this is the only
|       terminal that has no name.  Odd.
| 
| Should we see what look to see if StrongSwan has improved the table?

Yes, we should.  OID 89's anomaly indicated a bug, fixed by
strongswan over 3 years ago.

<http://wiki.strongswan.org/projects/strongswan/repository/revisions/ba1ad6c430fbabc3dd24e5e9fc13926bae042110>
/*
 * Check Libreswan's oid_names table
 *
 * compile: gcc -g -Iinclude -Wall check-oid.c
 *
 * DHR 2014 Apr 28
 */
#include <stdio.h>
#include <assert.h>

#include "lib/libswan/oid.c"

static const int max_oid = sizeof(oid_names) /  sizeof(oid_names[0]);

static void check_subtable(int basement, int oid, int roof)
{
        assert(oid <= roof);
        while (oid != roof) {
                const oid_t *o = &oid_names[oid];
                /* next alternative (or end) */
                int alt = o->next == 0 ? roof : o->next;

                assert(oid < alt);
                assert(alt <= roof);
                assert(oid_names[alt-1].down == 0);     /* must be terminal */

                if (o->octet <= basement)
                        printf("OID %d octet code steps backward from 0x%2x to 
0x%2x\n",
                                oid, basement, o->octet);
                assert(o->down == 0 || o->down == 1);   /* down is bool */
                assert(o->next != 0 || o->down == 1 || oid + 1 == roof);

                if (o->down) {
                        check_subtable(-1, oid + 1, alt);
                } else {
                        /* terminal */
                        assert(oid + 1 == alt);
                        if (o->name[0] == '\0')
                                printf("OID %d is terminal but has no name\n", 
oid);
                }

                basement = o->octet;
                oid = alt;
        }
}

int main()
{
        check_subtable(-1, 0, max_oid);
        return 0;
}
_______________________________________________
Swan-dev mailing list
[email protected]
https://lists.libreswan.org/mailman/listinfo/swan-dev

Reply via email to