From owner-freebsd-current@FreeBSD.ORG Tue Feb 19 09:35:51 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8DE3A8EC for ; Tue, 19 Feb 2013 09:35:51 +0000 (UTC) (envelope-from lokedhs@gmail.com) Received: from mail-ie0-x22d.google.com (ie-in-x022d.1e100.net [IPv6:2607:f8b0:4001:c03::22d]) by mx1.freebsd.org (Postfix) with ESMTP id 62B87B90 for ; Tue, 19 Feb 2013 09:35:51 +0000 (UTC) Received: by mail-ie0-f173.google.com with SMTP id 9so8177285iec.32 for ; Tue, 19 Feb 2013 01:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=W5YCDERy42Y1LxVMQWOC05e/Y8YyUG9ApX+AxftNu8c=; b=GXqpt7UGzKWKLZVfVRzrSQ4Bt/Gx0YBy9NM4nvO/juptVZF490lj17kx/FUTwHNEj/ 4/+RLiTkBMOPDJzJU2yjcm0fkxT+Yc2LTvJ0hXIXiRWxVn14pT/06MJTTx6/Q+qF4I92 cqSoIDX+0nyU2pln5iJG2U35+i8iOyJhacaCVpadaJNgsURlhirFINxJ9lxfQAGJdGUi SdRj4xOxF4h+Jb1/YpJVN0vNpCh0fG/Qnb6tjxc4GW1ohULiOVhQVvfUxN7jtTFwSysH /wy2bEX81+NnOb8MldTMK0vU0I3PjpmAbBDXs6UulevVd9P7vodsS0kudNulAycAsJ+5 zkyQ== MIME-Version: 1.0 X-Received: by 10.50.150.167 with SMTP id uj7mr9227937igb.1.1361266551120; Tue, 19 Feb 2013 01:35:51 -0800 (PST) Received: by 10.64.110.162 with HTTP; Tue, 19 Feb 2013 01:35:50 -0800 (PST) In-Reply-To: <20130219093142.GA1459@pm513-1.comsys.ntu-kpi.kiev.ua> References: <477291850.3084864.1361113135205.JavaMail.root@erie.cs.uoguelph.ca> <20130219093142.GA1459@pm513-1.comsys.ntu-kpi.kiev.ua> Date: Tue, 19 Feb 2013 17:35:50 +0800 Message-ID: Subject: Re: Possible bug in NFSv4 with krb5p security? From: =?ISO-8859-1?Q?Elias_M=E5rtenson?= To: Andrey Simonenko Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Rick Macklem , Benjamin Kaduk , freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2013 09:35:51 -0000 On 19 February 2013 17:31, Andrey Simonenko wrote: It can require bigger buffer, since root can get the pw_password field > in the struct passwd{}. > > Since sysconf(_SC_GETPW_R_SIZE_MAX) does not work on FreeBSD, the buffer > for getpwnam_r() call should have at least (2 * MAXLOGNAME + 2 * > MAXPATHLEN + > _PASSWORD_LEN + 1) bytes (it is unclear how much is required for pw_gecos). > > This buffer can be dynamically reallocated until getpwnam_r() is not > return ERANGE error (the following code has not been compiled and > verified): > Is this really a better solution than to aim high right away? A series of malloc() calls should certainly have much higher overhead than the previous stack-allocated solution. A better compromise would be to do the lookup in a separate function, that allocates the buffer using alloca() instead, yes? Regards, Elias