From owner-freebsd-standards Mon Oct 21 12:50: 4 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B0DF837B401 for ; Mon, 21 Oct 2002 12:50:02 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E553A43E4A for ; Mon, 21 Oct 2002 12:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g9LJo1x3091564 for ; Mon, 21 Oct 2002 12:50:01 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9LJo1qb091563; Mon, 21 Oct 2002 12:50:01 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB43837B40A for ; Mon, 21 Oct 2002 12:47:33 -0700 (PDT) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 318F243E3B for ; Mon, 21 Oct 2002 12:47:33 -0700 (PDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.3/8.12.5) with ESMTP id g9LJlWgQ066184 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Mon, 21 Oct 2002 15:47:32 -0400 (EDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.3/8.12.5/Submit) id g9LJlWP8066183; Mon, 21 Oct 2002 15:47:32 -0400 (EDT) (envelope-from wollman) Message-Id: <200210211947.g9LJlWP8066183@khavrinen.lcs.mit.edu> Date: Mon, 21 Oct 2002 15:47:32 -0400 (EDT) From: Garrett Wollman Reply-To: Garrett Wollman To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/44356: strerror_r() has impermissible failure mode Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 44356 >Category: standards >Synopsis: strerror_r() has impermissible failure mode >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Oct 21 12:50:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Garrett Wollman >Release: FreeBSD 5.0-CURRENT i386 >Organization: MIT LCS >Environment: System: FreeBSD khavrinen.lcs.mit.edu 5.0-CURRENT FreeBSD 5.0-CURRENT #608: Tue Apr 30 19:29:33 EDT 2002 root@:/usr/src/sys/i386/compile/KHAVRINEN i386 >Description: If an unrecognized error number is passed to strerror_r(), the buffer is left unchanged. XSH6 page 1416, lines 43783ff says: The strerror_r( ) function shall map the error number in errnum to a locale-dependent error message string and shall return the string in the buffer pointed to by strerrbuf, with length buflen. The consensus on the Austin Group list seems to be that strerror_r() must always put something in the buffer provided, even if a specific error message is not available for whatever reason. In our implementation, the buffer is only filled in when the error number is recognized (even if the buffer is too small). >How-To-Repeat: char buf[1234]; buf[0] = '\0'; strerror_r(12345678, buf, sizeof buf); assert(buf[0] != '\0'); >Fix: Move all of the `unknown error' processing from strerror() to strerror_r(). >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message