From owner-freebsd-questions@FreeBSD.ORG Mon Jun 20 19:53:28 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DAEA106566B for ; Mon, 20 Jun 2011 19:53:28 +0000 (UTC) (envelope-from chrruwe@googlemail.com) Received: from mail-fx0-f68.google.com (mail-fx0-f68.google.com [209.85.161.68]) by mx1.freebsd.org (Postfix) with ESMTP id F03458FC17 for ; Mon, 20 Jun 2011 19:53:27 +0000 (UTC) Received: by fxm15 with SMTP id 15so293820fxm.7 for ; Mon, 20 Jun 2011 12:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id:in-reply-to :references:reply-to:x-mailer:mime-version:content-type :content-transfer-encoding; bh=4Z1VHSQ3ZmFtGKb86Gtv7QbrO7cxywitd5Inznk8TiE=; b=kMDidXV6YlauMY1dnwMIwKWOYWB7BfyT17W6IbOpI9YgABWc2DswCo05cL/OxEtD6o /2wUQIQR37lQu0ea2RO+sMoEeZQmDndsX+YnnqjcORWoUeaXMqFGON63rSozntH0UiXC OLTtO6h+qVOsFkVkotFg1VIISkaQeDAKZEZ90= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:reply-to :x-mailer:mime-version:content-type:content-transfer-encoding; b=BQDqyiWjZjGLEEY7VqjtJnNM1Jbi2vGL/FPHx/cI6nPYNPj0xQ+kJ9lC0WyWlXT8By xpreRe9kqYOnLptZamkpIzV+UOkBAKT3TS/DlPHLQK9Ov4tixvVin4BkjxZ1hI2Ty2jy uPhyhvGgQDZPPTTN+T1SQng3sldFib4VARr1o= Received: by 10.223.2.205 with SMTP id 13mr1091479fak.138.1308599605045; Mon, 20 Jun 2011 12:53:25 -0700 (PDT) Received: from dijkstra (p5B37B387.dip.t-dialin.net [91.55.179.135]) by mx.google.com with ESMTPS id n7sm2999164fam.19.2011.06.20.12.53.23 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Jun 2011 12:53:24 -0700 (PDT) Date: Mon, 20 Jun 2011 21:53:18 +0200 From: "Christopher J. Ruwe" To: freebsd-questions@freebsd.org Message-ID: <20110620215318.0bea0f77@dijkstra> In-Reply-To: <20110619225038.1dcda180@dijkstra> References: <20110618180858.41cda851@dijkstra> <20110619225038.1dcda180@dijkstra> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.1; amd64-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: problem report bin/157732 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: cjr@cruwe.de List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2011 19:53:28 -0000 > > 2. You are probably right in checking to make sure that bumping > > up that limit of the hostname length would not result in a buffer > > overflow somewhere downstream. > > You should probably check that inet_addr() and all other relevant > > functions define the variables of the type and length that can > > handle this longer input. > > > > I noticed that some Linux (2.6.26-2-686) I had access to, was > > capable of handling that long host name. So, you might want to pick > > at how it is handled by Linux. (Unless that might create some sort > > of copyright/license issues.) > > Looking over the fence, the Linux traceroute calls getaddr(), which > does check against hostname length and also has a limit of 64. > Calling traceroute with anything longer than 64 chars will result in a > "traceroute: hostname "abcdefghi.abcdefghi.abcdefghi.ab..." is too > long" error. > > Solaris, on the other hand, calls a getaddr() in getaddrinfo > (http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libsocket/inet/getaddrinfo.c), > which checks against a MAXHOSTNAMELENGTH=256 defined in netdb.h > (http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libresolv/netdb.h). > Anyway, it performs for the example from the PR. When supplying an > arbitary string longer than 255 chars, traceroute from Solaris > terminates with a memory allocation error as defined in EAI_MEMORY > (also defined in netdb.h). > > TrustedBSD has the same <64 chars limit and is, I gather, not too > dissimilar. > > As an aside, inet_addr() is, i gather, part of POSIX > (http://pubs.opengroup.org/onlinepubs/009695399/functions/inet_addr.html), > so I wonder, why so many do not implement inet_getaddr(), but have > some home-brew called get_addr()? Sorry, I got confused. Using inet_addr() to lookup a hostname is complete rubbish, it's getaddrinfo(). And of course getaddrinfo() is part of POSIX (http://pubs.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html). Hope I'll not get too confused to make any sense ... -- Christopher J. Ruwe TZ GMT + 2