From nobody Fri May 17 09:37:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1713438166723988.6760620703457; Thu, 18 Apr 2024 04:02:46 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5E4831C25; Thu, 18 Apr 2024 07:02:45 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CB8A1EA0; Thu, 18 Apr 2024 07:00:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B65CA1BAA; Thu, 18 Apr 2024 07:00:56 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F16C2EA0 for ; Thu, 18 Apr 2024 07:00:54 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-bD8le9uhNym6WnZu6EAChA-1; Thu, 18 Apr 2024 07:00:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C27733820EA5 for ; Thu, 18 Apr 2024 11:00:52 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DF1A1121306 for ; Thu, 18 Apr 2024 11:00:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: bD8le9uhNym6WnZu6EAChA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] libvirt_nss: Fix ERROR() macro Date: Thu, 18 Apr 2024 13:00:48 +0200 Message-ID: <9b33d4276cf21d5cfc14686d144c73627b62ac63.1713438048.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: A25CT6VUJEJQPDUOM6OSCXYTZHF43KMU X-Message-ID-Hash: A25CT6VUJEJQPDUOM6OSCXYTZHF43KMU X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713438167250100001 The purpose of ERROR() macro in our NSS module is to print error message provided as arguments followed by error string corresponding to errno. Historically, we've used strerror_r() for that (please note, we want our NSS module to be free of libvirt internal functions, or glib even - hence, g_strerror() is off the table). Now strerror_r() is documented as: Returns ... a pointer to a string that the function stores in buf, or a pointer to some (immutable) static string (in which case buf is unused). Therefore, we can't rely the string being stored in the buf and really need to store the retval and print that instead. While touching this area, decrease the ebuf size, since its current size (1KiB) is triggering our stack limit (2KiB) in some cases. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/nss/libvirt_nss.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/nss/libvirt_nss.h b/tools/nss/libvirt_nss.h index 2bb313f329..5f356618f3 100644 --- a/tools/nss/libvirt_nss.h +++ b/tools/nss/libvirt_nss.h @@ -37,11 +37,11 @@ # define NULLSTR(s) ((s) ? (s) : "") # define ERROR(...) \ do { \ - char ebuf[1024]; \ - strerror_r(errno, ebuf, sizeof(ebuf)); \ + char ebuf[512]; \ + const char *errmsg =3D strerror_r(errno, ebuf, sizeof(ebuf)); \ fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \ fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, " : %s\n", ebuf); \ + fprintf(stderr, " : %s\n", errmsg); \ fprintf(stderr, "\n"); \ } while (0) =20 --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org