1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 09:40:25 +02:00

Fix buffer overread in string-locale-ci=? and related functions

* libguile/i18n.c (u32_locale_casecoll): Take lengths of incoming
strings as parameters rather than assuming "nul" termination.
(compare_u32_strings_ci): Pass string lengths as computed from the
Scheme strings.
* test-suite/tests/i18n.test ("text collation (English)"): Add a test
case.

Thanks a million to Rob Browning for the report.
This commit is contained in:
Andy Wingo 2021-03-15 21:23:43 +01:00
parent 5a1a1eee50
commit d87b57a00b
2 changed files with 18 additions and 12 deletions

View file

@ -1,8 +1,7 @@
;;;; i18n.test --- Exercise the i18n API. -*- coding: utf-8; mode: scheme; -*-
;;;;
;;;; Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012,
;;;; 2013, 2014, 2015, 2016, 2017, 2018 Free Software Foundation, Inc.
;;;; Ludovic Courtès
;;;; Copyright (C) 2006-2007,2009-2019,2021 Free Software Foundation, Inc.
;;;; Author: Ludovic Courtès
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -75,6 +74,11 @@
(string-locale-ci=? "Hello" "HELLO"
(make-locale (list LC_COLLATE) "C"))))
(pass-if "string-locale-ci=?, bis"
(let* ((strings (list "⇒a" "⇒b"))
(heads (map (lambda (s) (substring/shared s 0 1)) strings)))
(apply string-locale-ci=? heads)))
(pass-if "string-locale-ci<?"
(and (string-locale-ci<? "hello" "WORLD")
(string-locale-ci<? "hello" "WORLD"