Wireshark-dev: Re: [Wireshark-dev] ASN.1 integers and types

From: Anders Broman <a.broman@xxxxxxxxxxxx>
Date: Tue, 10 Jul 2012 06:20:34 +0200
Guy Harris skrev 2012-07-10 01:34:
On Jul 9, 2012, at 2:41 PM, buildbot-no-reply@xxxxxxxxxxxxx wrote:

The Buildbot has detected a new failure on builder OSX-10.5-x86 while building Wireshark (development).
Full details are available at:
http://buildbot.wireshark.org/trunk/builders/OSX-10.5-x86/builds/1821

Buildbot URL: http://buildbot.wireshark.org/trunk/

Buildslave for this Build: osx-10.5-x86

Build Reason: scheduler
Build Source Stamp: 43629
Blamelist: pascal

BUILD FAILED: failed compile
/bin/sh ../../libtool --tag=CC   --mode=compile ccache gcc -DHAVE_CONFIG_H -I. -I../.. -I./../.. -I./.. -I/usr/local/include   -I/usr/local/include  -DINET6 -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -DGTK_DISAB
LE_SINGLE_INCLUDES -D_U_="__attribute__((unused))"  -D_FORTIFY_SOURCE=2 -I/usr/local/include  '-DPLUGIN_DIR="/usr/local/lib/wireshark/plugins/1.9.0-SVN-43629"' -Werror -no-cpp-precomp -g -O2 -Wall -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wpointer-arith -Wno-pointer-sign -Wcast-align -Wformat-security -Wold-style-definition -I/usr/X11/include/freetype2 -I/usr/X11/include -I/usr/X11/include/libpng12 -I/usr/X11/include/pixman-1 -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include -I/usr/local/include/atk-1.0 -I/usr/local/include/cairo -I/usr/local/include/pango-1.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include   -MT libdissectors_la-packet-mpeg-audio.lo -MD -MP -MF .deps/libdissectors_la-packet-mpeg-audio.Tpo -c -o libdissectors_la-packet-mpeg-audio.lo `test -f 'packet-mpeg-audio.c' || echo './'`packet-mpeg-audio.c
cc1: warnings being treated as errors
../../asn1/lpp/lpp.cnf: In function 'dissect_lpp_INTEGER_M2147483648_2147483647':
../../asn1/lpp/lpp.cnf:1328: warning: this decimal constant is unsigned only in ISO C90

The offending code is

static int
dissect_lpp_INTEGER_M2147483648_2147483647(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
   offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
                                                             -2147483648, 2147483647U, NULL, FALSE);

   return offset;
}

The two integral constants in that call correspond to guint32 arguments; the first of those is, obviously, negative.

ITU-T Recommendation X.680 says

	3.8.40	integer type: A simple type with distinguished values which are the positive and negative whole numbers, including zero (as a single value).

		NOTE � Particular encoding rules limit the range of an integer, but such limitations are chosen so as not to affect any user of ASN.1.

and I don't see anything about a type that includes only the positive whole numbers, including zero - i.e., no unsigned type - so perhaps, if we're to strictly interpret ASN.1, either all integral types should be signed, and any integral type with values>  2147483647 should be 64-bit (or we should introduce bignums so that we don't have to bail out on *any* ASN.1 number) or, at least, all *unconstrained* integral types should be signed and 64-bit (or, if we introduce bignums, bignum), with only integral types constrained to a minimum value>= 0 unsigned, and with the width of the type chosen based on the constraints.

The right short-term fix might be to make the arguments to dissect_per_constrained_integer() be gint64 rather than guint32 - and perhaps have the pointer for the returned value be a gint64 * rather than a guint32 *.
Yes I vote for that.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list<wireshark-dev@xxxxxxxxxxxxx>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
              mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe