From patchwork Mon Jun 10 20:09:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 91833 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57C90385DDD1 for ; Mon, 10 Jun 2024 20:10:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id B98E4385DDC4 for ; Mon, 10 Jun 2024 20:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B98E4385DDC4 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B98E4385DDC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; cv=none; b=WzASI9lDhimHl+NEXMGsnkRJvtRjG9A2eyQrg0BW2gY7aHz+pkL1pqrCVx+ErCNDZmxbryF2EahnTOLfQ4IX2wTiEGpqUs1+rV9FL0ENvvtvHR0QDUpOxC8xMp2mmjdShlR3qHDaTfAjpe0J5916qtm9mR7H0yRJA+OOjgkdCXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; c=relaxed/simple; bh=iwwXwDydgU4wDaYgH4AVHLvi4vpxP/f+V2gAeBXcxxE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=SVjCM5IlxPtwJYEHIcxSAGNE6GS064cHcbMQBlZRCLzTPg0pZ7pmhqNzNstJ2WHiNqYBZdiQwqaCCV0E7GCoU2ZMYcocyywEZagzZiRhvTLM+i77wUbg+ZthKc1mnykxFsiltYTnXmfrSckq7hMthxHCyCC9068z+F7F20q/8Tk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id B3690A0311; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uOJ31u4xoyby; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 885E6A0316; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1sGlKd-00000002aKm-0PLo; Mon, 10 Jun 2024 22:09:31 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 1/4] hurd: Fix lsetxattr return value Date: Mon, 10 Jun 2024 22:09:27 +0200 Message-ID: <20240610200930.616306-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> References: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org The manpage says that lsetxattr returns 0 on success, like setxattr. --- sysdeps/mach/hurd/lsetxattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/lsetxattr.c b/sysdeps/mach/hurd/lsetxattr.c index 3f5d335a1a..49487f78fb 100644 --- a/sysdeps/mach/hurd/lsetxattr.c +++ b/sysdeps/mach/hurd/lsetxattr.c @@ -32,5 +32,5 @@ lsetxattr (const char *path, const char *name, const void *value, size_t size, return -1; err = _hurd_xattr_set (port, name, value, size, flags); __mach_port_deallocate (__mach_task_self (), port); - return err ? __hurd_fail (err) : size; + return __hurd_fail (err); } From patchwork Mon Jun 10 20:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 91835 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A0BD385700F for ; Mon, 10 Jun 2024 20:10:35 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id B239C385DC20 for ; Mon, 10 Jun 2024 20:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B239C385DC20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B239C385DC20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; cv=none; b=BWazHfplMhzKfJtD3ui+nJ/z7CMzNdRalwUZIxWOamnNoGH1lN5anAUWmVjB0gol/En96gd95aV+5gyrgsPAtcMM0JDqY6u7fOcg5euXyxxetLVoa7BlMGGl7vWtlVNQkPVnMZwR6YMaIISjs6IaWoA6d78dIsiHUXzvCNgyJ2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; c=relaxed/simple; bh=hc30VrVem9zlxSWYqKiFaSxSf7V+IkxJGaQSRapq4gM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=w0dsPdMWvrbkgAOs7Svma5vwZV7jVf3mpcOwMyXHA4eQVR3v0aYDxbpyzeU81iQKIH4zTt0jttHAvUsJUBngJFuY/s2lEXtbcr9LM8GHlZyph0y/EbwZVWf3yK5YGT2Llz17xpeRxSzJ8WYFVrtkZQ2yoDM/zUcDu7WeVeSjev8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id C377EA0316; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w4uB3uzwJ-0w; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 8C630A0317; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1sGlKd-00000002aKp-0UgJ; Mon, 10 Jun 2024 22:09:31 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited 2/4] hurd: Fix getxattr("gnu.translator") returning ENODATA Date: Mon, 10 Jun 2024 22:09:28 +0200 Message-ID: <20240610200930.616306-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> References: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org When no translator is set, __file_get_translator would return EINVAL which is a confusing value. Better check for a passive translation before getting the value. --- hurd/xattr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hurd/xattr.c b/hurd/xattr.c index 0715ad7b02..f613d47c83 100644 --- a/hurd/xattr.c +++ b/hurd/xattr.c @@ -61,7 +61,16 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) { char *buf = value; mach_msg_type_number_t bufsz = value ? *size : 0; - error_t err = __file_get_translator (port, &buf, &bufsz); + struct stat64 st; + error_t err; + + err = __io_stat (port, &st); + if (err) + return err; + if ((st.st_mode & S_IPTRANS) == 0) + return ENODATA; + + err = __file_get_translator (port, &buf, &bufsz); if (err) return err; if (value != NULL && *size < bufsz) From patchwork Mon Jun 10 20:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 91836 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B45FD385B532 for ; Mon, 10 Jun 2024 20:11:28 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id B26BB385DDC2 for ; Mon, 10 Jun 2024 20:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B26BB385DDC2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B26BB385DDC2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; cv=none; b=ewfHLKmSRV7eWqNR7NfRKwK2iroIjaR8aaNqM4DvolgnOFfoE1M2ByNehfh7zLjmGy95vFzFzpqizxd0VWoqddH7dOmSnuVKKTJsh99pwow772OkVvgLqq3/0YL04L04K28yWW0QyadmKV1fSwCJIb9mTWM78kgGy1pOKBTkh1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; c=relaxed/simple; bh=zfVp1VFO22EcBF/4qZ9U4HYhXkI4Uu/tNWVsohAhGGk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ZWdsyC/nOVgcGhUERKaxcOTeYfL6C8GxT7mbYCV+SEecWXqEDeS6HJ7y/x+m/fuMmQ8/vSSBIAxZnSWoMlXQJWa9gbJKsFcyL05Eqz17dHfwGAeM2JFxtEHNrcbB01rWeun9sz2NRQj06QOPThGiYdEQE5mA1ZDTCO64qZMDnqM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id D9A9CA0317; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8CqYSL5eEjOy; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 94328A032A; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1sGlKd-00000002aKs-0a3m; Mon, 10 Jun 2024 22:09:31 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 3/4] hurd: Fix setxattr return value on replacing Date: Mon, 10 Jun 2024 22:09:29 +0200 Message-ID: <20240610200930.616306-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> References: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org When XATTR_REPLACE is set we shall succeed when the value already exists, and fail with ENODATA otherwise, instead of the converse. --- hurd/xattr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hurd/xattr.c b/hurd/xattr.c index f613d47c83..1a84c90db8 100644 --- a/hurd/xattr.c +++ b/hurd/xattr.c @@ -158,10 +158,9 @@ _hurd_xattr_set (io_t port, const char *name, const void *value, size_t size, if (err) return err; if (bufsz > 0) - { - __munmap (buf, bufsz); - return ENODATA; - } + __munmap (buf, bufsz); + else + return ENODATA; } return __file_set_translator (port, FS_TRANS_SET | ((flags & XATTR_CREATE) From patchwork Mon Jun 10 20:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 91834 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EFCE385DDE8 for ; Mon, 10 Jun 2024 20:10:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id BC378385DDC5 for ; Mon, 10 Jun 2024 20:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC378385DDC5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BC378385DDC5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; cv=none; b=KtOAdGfJImD+/V26kKYis9tASGiTTZeqhO/T31FaNw5rOXcOv/POUpy2w34pqRjypXeGk7FsW70ZsCtHwMsrPMaPKREnUaGZGz1ZPk8CKZubl+wDvfDldreWKgsazG3+JlhIOfEGTWUI8KnfUf5WPwb9AQYKux8abE8k6lChExQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718050175; c=relaxed/simple; bh=SOSGBPDi2Qg9pvXIPfAXmDBjLiCxyVv5KgoE3LAS2E4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XH4mOMpPd32Q8o/LvWSx5BpWAJsL+GOnzHLa2SUUzAEgJsEwnVwPOEqoGxXdkDjpOBfv/D3tLmZ+MzKuBbPtHi7V5IxmRLdGajn60algPhrrKVKkJiisgtJM2Myn8v+FUYzOmj5xTP5GYyj3i9Z1qvZywNh3gc307k43Ch9EXOc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id E3D4EA032A; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gybFqyDtx0_s; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 9D66CA032B; Mon, 10 Jun 2024 22:09:31 +0200 (CEST) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1sGlKd-00000002aKv-0gF9; Mon, 10 Jun 2024 22:09:31 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 4/4] hurd: Fix getxattr/listxattr returning ERANGE Date: Mon, 10 Jun 2024 22:09:30 +0200 Message-ID: <20240610200930.616306-5-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> References: <20240610200930.616306-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org The manpage says that when the passed size is zero, they should set the expected size and return 0. ERANGE shall be returned only when the non-zero passed size is not large enough. --- hurd/xattr.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/hurd/xattr.c b/hurd/xattr.c index 1a84c90db8..2d83edf2fe 100644 --- a/hurd/xattr.c +++ b/hurd/xattr.c @@ -50,7 +50,15 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) else if (value) { if (*size < sizeof st.st_author) - return ERANGE; + { + if (*size > 0) + return ERANGE; + else + { + *size = sizeof st.st_author; + return 0; + } + } memcpy (value, &st.st_author, sizeof st.st_author); } *size = sizeof st.st_author; @@ -73,12 +81,21 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) err = __file_get_translator (port, &buf, &bufsz); if (err) return err; - if (value != NULL && *size < bufsz) + + if (*size < bufsz) { if (buf != value) __munmap (buf, bufsz); - return ERANGE; + + if (*size > 0) + return ERANGE; + else + { + *size = bufsz; + return 0; + } } + if (buf != value && bufsz > 0) { if (value != NULL) @@ -201,7 +218,7 @@ _hurd_xattr_list (io_t port, void *buffer, size_t *size) if (st.st_mode & S_IPTRANS) add ("gnu.translator"); - if (buffer != NULL && total > *size) + if (*size > 0 && total > *size) return ERANGE; *size = total; return 0;