From owner-freebsd-bugs@freebsd.org Sat Aug 5 11:43:18 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE550DD07DA for ; Sat, 5 Aug 2017 11:43:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC8D371F41 for ; Sat, 5 Aug 2017 11:43:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v75BhIBt094054 for ; Sat, 5 Aug 2017 11:43:18 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 221224] setlocale.c does not properly detect if locale contains too many slashes Date: Sat, 05 Aug 2017 11:43:17 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: leonard.r.koenig@googlemail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Aug 2017 11:43:19 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221224 --- Comment #1 from Leonard K=C3=B6nig --- i actually does get increased in line 172 so it does actually count the num= ber of sequences of slashes in the locale string (correctly). But while this works, setting i to 1 within a loop that doesn't use i is ve= ry confusing (as is the rest of the code). But even while i correctly counts the number of slashes it silently assumes that slashes are only used as separators between locales in a compound loca= le -- leading and trailing slashes are thus also counted which results in eg. "/1/2/3/4/5/6" to be seen as having 6 slashes (correct) but 6+1 locales (incorrect) in line 164 and also the first locale to be set to "/", the sec= ond to "1/" and the 6th to "5/". Ie: setlocale(LC_ALL, "/1/2/3/4/5/6") calls strlcpy(new_categories[i], loca= le, len+1) with: i | locale | len+1 | (new) categories[i] ---|----------------|-------|--------------------- 1 | "/1/2/3/4/5/6" | 1 | "/" 2 | "1/2/3/4/5/6" | 2 | "1/" 3 | "2/3/4/5/6" | 2 | "2/" 4 | "3/4/5/6" | 2 | "3/" 5 | "4/5/6" | 2 | "4/" 6 | "5/6" | 2 | "5/" --=20 You are receiving this mail because: You are the assignee for the bug.=