Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Apr 2000 01:20:24 -0700 (PDT)
From:      pavlin@catarina.usc.edu
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        pavlin@catarina.usc.edu
Subject:   misc/18251: inet_aton(204.08.126.0) failure
Message-ID:  <200004270820.BAA56964@gaudi.usc.edu>

next in thread | raw e-mail | index | archive | help

>Number:         18251
>Category:       misc
>Synopsis:       inet_aton() may fail for some addresses (e.g. 204.08.126.0)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 27 01:30:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Pavlin Ivanov Radoslavov
>Release:        FreeBSD 4.0-RELEASE i386
>Organization:
University of Southern California, Dept. of CS
>Environment:

	FreeBSD 4.0-RELEASE (but probably also true for FreeBSD-current)

>Description:

	inet_aton() may fail for some IPv4 addresses that may look OK.
	E.g. such address is 204.08.126.0 (note the '0' in front of '8',
	i.e. "08" is OK in base-10, but not valid in base-8
	(a fact that triggers the error because of the particular
	implemetation which uses strtoul()

>How-To-Repeat:

	Compile and execute the following code:


#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int
main()
{
    struct in_addr in_addr;
    char *s;

    s = "204.08.126.0";
    if (inet_aton(s, &in_addr) == 1)
	printf("OK\n");
    else
	printf("ERROR\n");
    
    exit (0);
}

>Fix:

	The problem is in the inet_aton() implementation in libc:
	/usr/src/lib/libc/net/inet_addr.c

	Older FreeBSD versions (e.g. FreeBSD-3.2) are OK, so one
	possible solution is to use the implementation from
	those older systems instead of the FreeBSD-4.0 solution.


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200004270820.BAA56964>