From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id ADC041F47C for ; Wed, 11 Jan 2023 19:46:00 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=clisp.org header.i=@clisp.org header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=nkXKamFs; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFh2M-0003oh-BR; Wed, 11 Jan 2023 14:45:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFh26-0003kv-Kt for bug-gnulib@gnu.org; Wed, 11 Jan 2023 14:45:12 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.23]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFh23-0005x6-5v for bug-gnulib@gnu.org; Wed, 11 Jan 2023 14:45:09 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1673466303; cv=none; d=strato.com; s=strato-dkim-0002; b=E6vMQ2RhShoU0cTlRXEyymn8YjEd/Lh/vALtLHb7wRDlGL5hsSXo0jxNCQBP+UDLb0 fq7XY9qswj+Lgd7RSu3BV0V2JhSMtXgaSLGHqWgm8GvmIc3C5PSpZ7zf2w7Dn0njG7u9 aVYgVLnJTDMfRYn1y6vYS5QWTcgXdfGEnXLwu/ZWVBAh9aZjIiUsY/0XW3IITAk+eSa4 VxRE1GzUdvWrUyDh8ioV6K3TRqJXLsNs3sGXfZ7ex1XM66pTs/MAp/M9u6mDC/htBLCL PTSUCSVcrFVhQ+gMnSgFWl+izQ00Ac0cJoutgX0H3/VGpzpXe+ai8p3o9jO2kCif7geP JKwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1673466303; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=OHwwXtGZSh7KR/0bq9MEH1dyxbt3QmadxJlminew124=; b=GNp9ssl6ePWe+PrKMdNLTzbhEH2PntfpVJ7iuxUIV9NYL2d+EtlQYiO8GKRmsOShKu 19r46LLYcKx0367xQTbk4dwIzWr5mY45YRT+aYwSbDVuGd3KtYgT+cZb5b26NU76vdUN c8E8p0PTW3wZTD5AHYTEihRxzArH/5rnfg0YX2K7F9shHs0xtVxxjGKH/olPejPcUYMA BIzFl20D6QTmqkryD4dPvNhcYKM3G9Ai3PsGhIuI6xDn+XOcREX/miY1hlteLJn4RAdz q+50ZWG+vaVAF0QI1EvWArqdGcVN5l+OD4zkS2mDpoebWg/bPGsisZxchG7T/O4a/Kdr tnbw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1673466303; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=OHwwXtGZSh7KR/0bq9MEH1dyxbt3QmadxJlminew124=; b=nkXKamFsxm8BLjCfY+nQulb+FlIT1i+XxbpMFCvTrGJwhWVtH5mIaRRJw2FKixt4es SyKGnBsfz4aM+HJRoFoO8aPqDElDPaxxSwIT7CUk4dPgV24T63CunlBppVdFngGDUsIt YEpdBM1GuLsqu8ZA0XdClDwTXLNz4KUmjWTBvyLyjqGD94Mr1jXUIBhp0YscSw+DUOMO M76Ix0vj8f8Ay9qKyCJYmq0kE82r1/VZKtTfKYQ6zgutTc8hSH5AC9AYykjmeQoyWyQp rFbPPBXrSTQJGRvGPdaeGgnRSdlYzVtcXsYd2RDq+OIm6ANKeQCwtf5CqLaW2rh60Aw8 uLGw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpOV1KfevSn/sVBN8TS9zA9aoIqWAw==" Received: from nimes.localnet by smtp.strato.de (RZmta 48.6.2 AUTH) with ESMTPSA id I8f358z0BJj32iM (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 11 Jan 2023 20:45:03 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: perror: Fix "perror clobbers strerror's buffer" problem on Android Date: Wed, 11 Jan 2023 20:45:03 +0100 Message-ID: <76359641.VQpxGFKSoK@nimes> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=85.215.255.23; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org In a testdir on Android 11, I see this test failure: FAIL: test-perror2 ================== ../../gltests/test-perror2.c:82: assertion 'STREQ (msg4, str4)' failed Aborted FAIL test-perror2 (exit status: 134) When I print the values of msg4 and str4, I get: msg4="Unknown error -5" str4="Unknown error 1729576" This means that perror() clobbers the strerror() buffer, at least in the case where errno < 0. But according to the Gnulib documentation, this should not happen. This patch fixes it. (I could have written an Autoconf test here, but it would need a cross-compilation guess anyway.) 2023-01-11 Bruno Haible perror: Fix "perror clobbers strerror's buffer" problem on Android. * m4/perror.m4 (gl_FUNC_PERROR): Set REPLACE_PERROR to 1 on Android. * doc/posix-functions/perror.texi: Mention the Android problem. diff --git a/doc/posix-functions/perror.texi b/doc/posix-functions/perror.texi index bbc2925d60..4c4a7e36dd 100644 --- a/doc/posix-functions/perror.texi +++ b/doc/posix-functions/perror.texi @@ -18,7 +18,7 @@ requires that the message declare it as a success, on some platforms: FreeBSD 8.2, OpenBSD 4.7, macOS 11.1. @item This function clobbers the @code{strerror} buffer on some platforms: -Cygwin 1.7.9. +Cygwin 1.7.9, Android 11. @item This function fails to print a useful a string for out-of-range integers on some platforms: diff --git a/m4/perror.m4 b/m4/perror.m4 index 3ff029de76..2545cb3487 100644 --- a/m4/perror.m4 +++ b/m4/perror.m4 @@ -1,4 +1,4 @@ -# perror.m4 serial 10 +# perror.m4 serial 11 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_PERROR], AC_REQUIRE([gl_HEADER_ERRNO_H]) AC_REQUIRE([gl_FUNC_STRERROR_R]) AC_REQUIRE([gl_FUNC_STRERROR_0]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([AC_CANONICAL_HOST]) dnl We intentionally do not check for the broader REPLACE_STRERROR_R, dnl since on glibc systems, strerror_r is replaced only for signature dnl issues, and perror is just fine. Rather, we only want to @@ -68,4 +68,9 @@ AC_DEFUN([gl_FUNC_PERROR], REPLACE_PERROR=1 ;; esac + dnl Does perror clobber the strerror buffer? + case "$host_os" in + # Yes on Android 11. + linux*-android*) REPLACE_PERROR=1 ;; + esac ])