[ PATCH ] Re: hexadecimal integers in user options

Jason Vas Dias jvdias at redhat.com
Mon Jan 24 19:58:40 UTC 2005


Hi -
Here's one way to fix the problem of not being 
able to parse hexadecimal 32-bit integer user
defined options, in a patch against dhcp-3.0.2rc3
source:

--- dhcp-3.0.2rc3/common/parse.c.fix-hex        2004-09-30
16:38:31.000000000 -0400
+++ dhcp-3.0.2rc3/common/parse.c        2005-01-24 14:24:48.472340000
-0500
@@ -4448,7 +4448,7 @@
              case 'l': /* Signed 32-bit integer... */
                token = peek_token (&val, (unsigned *)0, cfile);
              check_number:
-               if (token != NUMBER) {
+               if ( (token != NUMBER) && (token != NUMBER_OR_NAME) ) {
                      need_number:
                        if ((*fmt) [1] != 'o') {
                                parse_warn (cfile, "expecting number.");


RE: 

> 
> Is there a bugzilla (or other public bug-filing method) to report this
> bug?  Or, is the mere fact that it was discussed on the mailing list 
> sufficient to get the problem addressed?  Without guidance from a 
> maintainer / developer, I do not feel comfortable mucking with the
> parsing 
> routines fixes all of the problems without creating any regresssions. 
> Likewise, I don't want the problem to be forgotten.
> 
> Steve Friedman
> 
> On Tue, 18 Jan 2005, Steve Friedman wrote:
> 
> >
> > I was running dhcp-3.0pl2-6.16 on an FC1 system.  I just tried it on
> FC3 
> > (with dhcp-3.0.1-11) and had the same results.  So, I compiled from
> source 
> > dhcp-3.0.2rc3 and still got the failure.
> >
> > It seems that get_token() is returning NUMBER_OR_NAME and either the
> caller, 
> > get_token, or read_number isn't clever enough to realize that (in
> this case) 
> > it is a NUMBER.  I don't know the program flow well enough to know
> the best 
> > location to patch the problem.
> >
> > Steve
> >
> > On Tue, 18 Jan 2005, Glenn Satchell wrote:
> >
> >>   *** From dhcp-server -- To unsubscribe, see the end of this
> message. ***
> >> 
> >> Well that's ancient - apart from a couple of security bug fixes it
> >> would be probably 4 years old.
> >> 
> >> I'd definitely recommend an upgrade to 3.0.1, or 3.0.2rc3 which is
> the
> >> latest release candidate. There's a link on the web site to
> download
> >> RPMs.
> >> 
> >> regards,
> >> -glenn
> >> 
> >>> Date: Mon, 17 Jan 2005 10:09:48 -0500 (EST)
> >>> From: Steve Friedman <steve at adsi-m4.com>
> >>> 
> >>> I don't know how I forgot to include that in my initial message:
> >>> 
> >>> dhcp-3.0pl2-6.16 (it is a RedHat RPM)
> >>> 
> >>> Steve
> >>> 
> >>> On Sat, 15 Jan 2005, Glenn Satchell wrote:
> >>> 
> >>>>   *** From dhcp-server -- To unsubscribe, see the end of this
> message. 
> >>>> ***
> >>>> 
> >>>> The function that parses this is common/conflex.c get_token().
> That
> >>>> looks like it should be doing the right thing, but my C is a
> little
> >>>> rusty.
> >>>> 
> >>>> What version of dhcpd are you running?
> >>>> 
> >>>> regards,
> >>>> -glenn
> >>>> 
> >>>>> X-Original-To: dhcp-server at rc3.isc.org
> >>>>> Date: Fri, 14 Jan 2005 15:15:27 -0500 (EST)
> >>>>> From: Steve Friedman <steve at adsi-m4.com>
> >>>>> To: dhcp-server at isc.org
> >>>>> Subject: hexadecimal integers in user options
> >>>>> X-ecartis-version: Ecartis v1.0.0
> >>>>> X-original-sender: steve at adsi-m4.com
> >>>>> X-List-ID: <dhcp-server.isc.org>
> >>>>> 
> >>>>>    *** From dhcp-server -- To unsubscribe, see the end of this
> message. 
> >>>>> ***
> >>>>> 
> >>>>> 
> >>>>> I am confused about the parsing of hexadecimal integers in user
> options.
> >>>>> I have an unsigned integer user option.  If I set the value of
> the 
> >>>>> option
> >>>>> to a hexadecimal number that happens to only contain digits from
> 0-9, it
> >>>>> works (the client gets the option with the correct value). 
> However, if 
> >>>>> I
> >>>>> include the hexadecimal digits from A-F (or a-f), it fails with 
> >>>>> "expecting
> >>>>> number".  I've searched the mailing list archives and google,
> but can't
> >>>>> figure out why the parser would do this and/or how to resolve
> this
> >>>>> problem.
> >>>>> 
> >>>>> Example:
> >>>>> 
> >>>>>   option ADSI.blah code 3 = unsigned integer 32;
> >>>>> 
> >>>>>   option ADSI.blah  0x4100123;    # works --> hex value
> >>>>> 
> >>>>>   option ADSI.blah 0x4100ABC;     # doesn't work; get expecting
> number
> >>>>> 
> >>>>> 
> >>>>> What am I doing wrong?
> >>>>> 
> >>>>> Steve Friedman
> >>>>> 
> >>>>> 
> >>>>> 
> >>>>>
> -----------------------------------------------------------------------
> >>>>> List Archives : http://www.isc.org/ops/lists/
> >>>>> Unsubscribe   : http://www.isc.org/sw/dhcp/dhcp-lists.php
> >>>>> -or-          :
> mailto:dhcp-server-request at isc.org?Subject=unsubscribe
> >>>>>
> -----------------------------------------------------------------------
> >>>>> 
> >>>> 
> >>>> 
> >>>>
> -----------------------------------------------------------------------
> >>>> List Archives : http://www.isc.org/ops/lists/
> >>>> Unsubscribe   : http://www.isc.org/sw/dhcp/dhcp-lists.php
> >>>> -or-          :
> mailto:dhcp-server-request at isc.org?Subject=unsubscribe
> >>>>
> -----------------------------------------------------------------------
> >>>> 
> >>> 
> >>>
> -----------------------------------------------------------------------
> >>> List Archives : http://www.isc.org/ops/lists/
> >>> Unsubscribe   : http://www.isc.org/sw/dhcp/dhcp-lists.php
> >>> -or-          :
> mailto:dhcp-server-request at isc.org?Subject=unsubscribe
> >>>
> -----------------------------------------------------------------------
> >>> 
> >> 
> >> 
> >>
> -----------------------------------------------------------------------
> >> List Archives : http://www.isc.org/ops/lists/
> >> Unsubscribe   : http://www.isc.org/sw/dhcp/dhcp-lists.php
> >> -or-          :
> mailto:dhcp-server-request at isc.org?Subject=unsubscribe
> >>
> -----------------------------------------------------------------------
> >> 
> >
> 
> -----------------------------------------------------------------------
> List Archives : http://www.isc.org/ops/lists/
> Unsubscribe   : http://www.isc.org/sw/dhcp/dhcp-lists.php    
> -or-          :
> mailto:dhcp-server-request at isc.org?Subject=unsubscribe  
> -----------------------------------------------------------------------
> 


-- Attached file included as plaintext by Ecartis --
-- File: dhcp-3.0.2rc3-fix-hex.patch.txt

--- dhcp-3.0.2rc3/common/parse.c.fix-hex	2004-09-30 16:38:31.000000000 -0400
+++ dhcp-3.0.2rc3/common/parse.c	2005-01-24 14:24:48.472340000 -0500
@@ -4448,7 +4448,7 @@
 	      case 'l':	/* Signed 32-bit integer... */
 		token = peek_token (&val, (unsigned *)0, cfile);
 	      check_number:
-		if (token != NUMBER) {
+		if ( (token != NUMBER) && (token != NUMBER_OR_NAME) ) {
 		      need_number:
 			if ((*fmt) [1] != 'o') {
 				parse_warn (cfile, "expecting number.");




More information about the dhcp-hackers mailing list