From owner-freebsd-bugs@FreeBSD.ORG Wed Dec 24 01:20:20 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0EA4216A4CE for ; Wed, 24 Dec 2003 01:20:20 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0657E43D58 for ; Wed, 24 Dec 2003 01:20:16 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) hBO9KFFR086457 for ; Wed, 24 Dec 2003 01:20:15 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id hBO9KFJZ086456; Wed, 24 Dec 2003 01:20:15 -0800 (PST) (envelope-from gnats) Resent-Date: Wed, 24 Dec 2003 01:20:15 -0800 (PST) Resent-Message-Id: <200312240920.hBO9KFJZ086456@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Christoph Theis Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 594CC16A4CE for ; Wed, 24 Dec 2003 01:16:42 -0800 (PST) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B91643D31 for ; Wed, 24 Dec 2003 01:16:41 -0800 (PST) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.10/8.12.10) with ESMTP id hBO9GedL055761 for ; Wed, 24 Dec 2003 01:16:40 -0800 (PST) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.10/8.12.10/Submit) id hBO9GeDO055760; Wed, 24 Dec 2003 01:16:40 -0800 (PST) (envelope-from nobody) Message-Id: <200312240916.hBO9GeDO055760@www.freebsd.org> Date: Wed, 24 Dec 2003 01:16:40 -0800 (PST) From: Christoph Theis To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.0 Subject: misc/60539: segmentation fault in setlocale.c X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Dec 2003 09:20:20 -0000 >Number: 60539 >Category: misc >Synopsis: segmentation fault in setlocale.c >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Dec 24 01:20:15 PST 2003 >Closed-Date: >Last-Modified: >Originator: Christoph Theis >Release: 4.6.2 RELEASE >Organization: >Environment: >Description: I think there is a bug in setlocale.c 1.48), around line 190 The code reads locale = r; while (*locale == '/') ++locale; while (*++r && *r != '/') ; } while (*locale); 1. If the locale string does not end with an '/', r points to the ending '\0'. This means, the "while (*++r && *r != '/')" may run beyond the string end, if the next character is not a '\0', to. The break condition "while (*locale);" comes to late. I think, the correct condition would read "while (*r++ && *r != '/')". 2. What happens, if there were more slashes in the locale string? "while (*locale == '/')" would run to the end of those sequence of '/', "while (*++r && *r != '/')" would advance r just one char. Thus, locale is behind r giving negative length. I think, correct would be, to call "r = locale" before advancing r. Thus, the code shall read: locale = r; while (*locale == '/') ++locale; r = locale; while (*r && *r != '/') ++r; } while (*locale); You can't set empty categories then, that is, "//" in the string would not keep the corresponding categories unchanged. But that is the same behaviour as current. >How-To-Repeat: Difficult. My locale string was de_AT.ISO8859-1/de_AT.ISO8859-1/de_AT.ISO8859-1/C/de_AT.ISO8859-1/de_AT.ISO8859-1 >Fix: >Release-Note: >Audit-Trail: >Unformatted: