unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38794: 26.1; Warnings in w32 build
@ 2019-12-29 16:04 Cecilio Pardo
  2019-12-29 17:20 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Cecilio Pardo @ 2019-12-29 16:04 UTC (permalink / raw)
  To: 38794


Severity: wishlist
Tags: patch

I am getting some warnings building with mingw64, using gcc 9.2.0. It
complies about possible buffer overruns with sprintf. Maybe upgrade to snprintf?

This is the warnings message:

addpm.c: In function 'main':
addpm.c:291:37: warning: '\bin\' directive writing 5 bytes into a region of size between 2 and 261 [-Wformat-overflow=]
  291 |        sprintf (full_emacs_path, "%s\\bin\\%s", emacs_path, prog_name);
      |                                     ^~~~~~~
addpm.c:291:8: note: 'sprintf' output between 18 and 277 bytes into a destination of size 261
  291 |        sprintf (full_emacs_path, "%s\\bin\\%s", emacs_path, prog_name);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


diff --git a/nt/addpm.c b/nt/addpm.c
index 3fd1b1bdc0..7da1fb5424 100644
--- a/nt/addpm.c
+++ b/nt/addpm.c
@@ -257,7 +257,7 @@ main (int argc, char *argv[])
 	      char full_emacs_path[MAX_PATH + 1];
 	      IPersistFile *lnk;
 	      strcat (start_folder, "\\Emacs.lnk");
-	      sprintf (full_emacs_path, "%s\\bin\\%s", emacs_path, prog_name);
+	      snprintf (full_emacs_path, sizeof (full_emacs_path), "%s\\bin\\%s", emacs_path, prog_name);
 	      IShellLinkA_SetPath (shortcut, full_emacs_path);
 	      IShellLinkA_SetDescription (shortcut, "GNU Emacs");
 	      result = IShellLinkA_QueryInterface (shortcut, &IID_IPersistFile,
@@ -288,7 +288,7 @@ main (int argc, char *argv[])
 	      char full_emacs_path[MAX_PATH + 1];
 	      IPersistFile *lnk;
 	      strcat (start_folder, "\\Emacs.lnk");
-	      sprintf (full_emacs_path, "%s\\bin\\%s", emacs_path, prog_name);
+	      snprintf (full_emacs_path, sizeof (full_emacs_path), "%s\\bin\\%s", emacs_path, prog_name);
 	      IShellLinkA_SetPath (shortcut, full_emacs_path);
 	      IShellLinkA_SetDescription (shortcut, "GNU Emacs");
 	      result = IShellLinkA_QueryInterface (shortcut, &IID_IPersistFile,




-- 
Cecilio Pardo





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#38794: 26.1; Warnings in w32 build
  2019-12-29 16:04 bug#38794: 26.1; Warnings in w32 build Cecilio Pardo
@ 2019-12-29 17:20 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2019-12-29 17:20 UTC (permalink / raw)
  To: Cecilio Pardo; +Cc: 38794

tags 38794 wontfix
close 38794
thanks

> From: Cecilio Pardo <cpardo@imayhem.com>
> Date: Sun, 29 Dec 2019 17:04:41 +0100
> 
> I am getting some warnings building with mingw64, using gcc 9.2.0. It
> complies about possible buffer overruns with sprintf. Maybe upgrade to snprintf?
> 
> This is the warnings message:
> 
> addpm.c: In function 'main':
> addpm.c:291:37: warning: '\bin\' directive writing 5 bytes into a region of size between 2 and 261 [-Wformat-overflow=]
>   291 |        sprintf (full_emacs_path, "%s\\bin\\%s", emacs_path, prog_name);
>       |                                     ^~~~~~~
> addpm.c:291:8: note: 'sprintf' output between 18 and 277 bytes into a destination of size 261
>   291 |        sprintf (full_emacs_path, "%s\\bin\\%s", emacs_path, prog_name);
>       |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

They are bogus, obviously, and we would like to deprecate and remove
addpm at some future point.  So I see no reason to make it compile
cleanly with GCC's too radical warning options.

So I'm closing this bug report.

Thank you anyway for your interest in Emacs and for providing a patch.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-29 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-29 16:04 bug#38794: 26.1; Warnings in w32 build Cecilio Pardo
2019-12-29 17:20 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).