[Bug 276960] /usr/include/*_asn1.h have unexpected target-dependent differences

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 10 Feb 2024 23:56:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276960

            Bug ID: 276960
           Summary: /usr/include/*_asn1.h have unexpected target-dependent
                    differences
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: emaste@freebsd.org

Compare /usr/include/*_asn1.h on e.g. i386 and amd64.

One example file:

ref13-amd64% grep pCPath /usr/include/rfc2459_asn1.h 
  pCPathLenConstraint   INTEGER (0..-1) OPTIONAL,

ref13-i386% grep pCPath /usr/include/rfc2459_asn1.h
  pCPathLenConstraint   INTEGER (0..2147483647) OPTIONAL,

Looking at the source file crypto/heimdal/lib/asn1/rfc2459.asn1:
pCPathLenConstraint     INTEGER (0..4294967295) OPTIONAL, -- really MAX

4294967295 is 2^32-1, 0xffffffff, and does not fit in a signed 32-bit int.

I believe this originates from contrib/flex/src/regex.c:
n = (int) strtol (s, endptr, base);

i386 has 32-bit long. There strtol truncates 4294967295 to INT_MAX (2147483647)
and sets errno to ERANGE, which is then ignored.

amd64 has 64-bit long, into which 4294967295 fits. This becomes -1 when cast to
int.

-- 
You are receiving this mail because:
You are the assignee for the bug.