From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.devel Subject: Re: Warning in svg_load_image Date: Wed, 23 Feb 2022 12:11:24 -0500 Message-ID: <87mtihmrq0.fsf@md5i.com> References: <87ilt8hcz4.fsf.ref@yahoo.com> <87ilt8hcz4.fsf@yahoo.com> <83r17wuz9s.fsf@gnu.org> <87y224e3x3.fsf@yahoo.com> <83pmnguy3w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7160"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Po Lu , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 23 18:16:26 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMvFZ-0001en-R7 for ged-emacs-devel@m.gmane-mx.org; Wed, 23 Feb 2022 18:16:26 +0100 Original-Received: from localhost ([::1]:40232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMvFY-00007w-OZ for ged-emacs-devel@m.gmane-mx.org; Wed, 23 Feb 2022 12:16:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMvCX-0006CA-3l for emacs-devel@gnu.org; Wed, 23 Feb 2022 12:13:17 -0500 Original-Received: from md5i.com ([75.151.244.229]:35490) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMvCU-0001Xe-Ep; Wed, 23 Feb 2022 12:13:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=md5i.com; s=dkim; h=Content-Type:MIME-Version:Message-ID:References:Date:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tyuYNipWwBtYgQv74FCM/W+Yta5PwXi61nfobjIifuI=; b=A9RjTqeqSmXITZJq7B4NnK2FvX tgGQRS36oP0f2hift5d6AgBV0Gnd7eb4abNfpE45iUwswhNZ0jfIw9jyqVcemRUDtSmkT/1NAsyGu kVTBkGxqDdunYizzbwjVGuv9Z; Original-Received: from abode ([192.168.177.1] helo=miko) by md5i.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1nMvCS-007WYk-2f; Wed, 23 Feb 2022 12:13:12 -0500 In-Reply-To: <83pmnguy3w.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 21 Feb 2022 15:51:15 +0200") Received-SPF: pass client-ip=75.151.244.229; envelope-from=mwd@md5i.com; helo=md5i.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286630 Archived-At: Eli Zaretskii writes: > "xmlns:xi=\"http://www.w3.org/2001/XInclude\" " > "style=\"color: #%06X; fill: currentColor;\" " > "width=\"%d\" height=\"%d\" preserveAspectRatio=\"none\" " > - "viewBox=\"0 0 %f %f\">" > + "viewBox=\"0 0 %5.0f %5.0f\">" > "" > "" > ""; > @@ -10801,7 +10801,9 @@ svg_load_image (struct frame *f, struct image *img, char *contents, > > if (buffer_size <= snprintf (wrapped_contents, buffer_size, wrapper, > foreground & 0xFFFFFF, width, height, > - viewbox_width, viewbox_height, > + /* Sanitize the viewBox dimensions. */ > + min (viewbox_width, 10000.), > + min (viewbox_height, 10000.), > background & 0xFFFFFF, > SSDATA (encoded_contents))) > goto rsvg_error; > So, a couple of questions and comments... As mentioned in other messages, % sizes affect only the minimum sizes of results, so changing those values shouldn't help. (It's possible that using * might, but only as a possible subversion of the heuristics that this warning uses.) The principled way to solve this would be to call the snprintf twice, the first time with a zero-sized buffer, and then to use the return value to allocate the actual buffer. This is a pessimisation, but I don't know if it's a bad one (it depends on how frequently this code would be called. Po Lu, what architecture are you compiling for? As I haven't been able to trigger this in my own builds, I am guessing that the fact that you are is due to differences in how the compiler is interpreting the possible range of values for %f and maybe for %d. What are sizeof(int) and sizeof(float) on this architecture? -- Michael Welsh Duggan (md5i@md5i.com)