From: "Óscar Fuentes" <ofv@wanadoo.es>
To: 6674@debbugs.gnu.org
Cc: Christoph <cschol2112@googlemail.com>,
Juanma@debbugs.gnu.org, Barranquero <lekktu@gmail.com>
Subject: bug#6674: [PATCH] bug#6674: fix assignment of grep-find-use-xargs on Windows/MS-DOS
Date: Mon, 02 Aug 2010 17:48:12 +0200 [thread overview]
Message-ID: <8739uxdnib.fsf_-_@telefonica.net> (raw)
In-Reply-To: <4C569D60.5040804@gmail.com> ("Laimonas Vėbra"'s message of "Mon, 02 Aug 2010 13:26:40 +0300")
Laimonas Vėbra <laimonas.vebra@gmail.com> writes:
> Isn't it wsprintf (used in cmdproxy.c to quote args and for other purposes):
> http://msdn.microsoft.com/en-us/library/ms647550(VS.85).aspx
>
> that imposes 1024 buffer/string length limit...?
2010-08-02 Óscar Fuentes <ofv@wanadoo.es>
* cmdproxy.c (main): use _snprintf instead of wsprintf. Fixes
bug#6647. wsprintf has a 1024 char limit on Windows.
--- a/nt/cmdproxy.c
+++ b/nt/cmdproxy.c
@@ -35,6 +35,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h> /* getenv */
#include <string.h> /* strlen */
+/* We don't want to include stdio.h because we are alreayd duplicating
+ lots of it here */
+int _snprintf(char *buffer, size_t count, const char *format, ...);
/******* Mock C library routines *********************************/
@@ -604,6 +607,7 @@ main (int argc, char ** argv)
{
char * p;
int extra_arg_space = 0;
+ int maxlen, remlen;
int run_command_dot_com;
progname = getenv ("COMSPEC");
@@ -635,21 +639,32 @@ main (int argc, char ** argv)
case path contains spaces (fortunately it can't contain
quotes, since they are illegal in path names). */
- buf = p = alloca (strlen (progname) + extra_arg_space +
- strlen (cmdline) + 16);
+ remlen = maxlen =
+ strlen (progname) + extra_arg_space + strlen (cmdline) + 16;
+ buf = p = alloca (maxlen + 1);
/* Quote progname in case it contains spaces. */
- p += wsprintf (p, "\"%s\"", progname);
+ p += _snprintf (p, remlen, "\"%s\"", progname);
+ remlen = maxlen - (p - buf);
/* Include pass_through_args verbatim; these are just switches
so should not need quoting. */
for (argv = pass_through_args; *argv != NULL; ++argv)
- p += wsprintf (p, " %s", *argv);
+ {
+ p += _snprintf (p, remlen, " %s", *argv);
+ remlen = maxlen - (p - buf);
+ }
if (run_command_dot_com)
- wsprintf(p, " /e:%d /c %s", envsize, cmdline);
+ {
+ _snprintf(p, remlen, " /e:%d /c %s", envsize, cmdline);
+ remlen = maxlen - (p - buf);
+ }
else
- wsprintf(p, " /c %s", cmdline);
+ {
+ _snprintf(p, remlen, " /c %s", cmdline);
+ remlen = maxlen - (p - buf);
+ }
cmdline = buf;
}
else
@@ -669,19 +684,27 @@ main (int argc, char ** argv)
else
path[0] = '\0';
- cmdline = p = alloca (strlen (progname) + extra_arg_space +
- strlen (path) + 13);
+ remlen = maxlen =
+ strlen (progname) + extra_arg_space + strlen (path) + 13;
+ cmdline = p = alloca (maxlen + 1);
/* Quote progname in case it contains spaces. */
- p += wsprintf (p, "\"%s\" %s", progname, path);
+ p += _snprintf (p, remlen, "\"%s\" %s", progname, path);
+ remlen = maxlen - (p - cmdline);
/* Include pass_through_args verbatim; these are just switches
so should not need quoting. */
for (argv = pass_through_args; *argv != NULL; ++argv)
- p += wsprintf (p, " %s", *argv);
+ {
+ p += _snprintf (p, remlen, " %s", *argv);
+ remlen = maxlen - (p - cmdline);
+ }
if (run_command_dot_com)
- wsprintf (p, " /e:%d", envsize);
+ {
+ _snprintf (p, remlen, " /e:%d", envsize);
+ remlen = maxlen - (p - cmdline);
+ }
}
}
next prev parent reply other threads:[~2010-08-02 15:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-20 3:49 bug#6674: PATCH: fix assignment of grep-find-use-xargs on Windows/MS-DOS Óscar Fuentes
2010-07-20 12:57 ` Juanma Barranquero
2010-07-20 13:39 ` Óscar Fuentes
2010-07-20 14:24 ` Óscar Fuentes
2010-07-20 15:18 ` Juanma Barranquero
2010-07-20 16:56 ` Eli Zaretskii
2010-07-20 17:28 ` Eli Zaretskii
2010-07-20 17:42 ` Juanma Barranquero
2010-07-20 19:51 ` Óscar Fuentes
2010-07-20 21:41 ` Eli Zaretskii
2010-07-20 22:18 ` Eli Zaretskii
2010-07-21 0:38 ` Christoph
2010-07-21 1:22 ` Óscar Fuentes
2010-08-02 10:26 ` Laimonas Vėbra
2010-08-02 15:23 ` Óscar Fuentes
2010-08-02 15:48 ` Óscar Fuentes [this message]
2010-08-02 17:11 ` bug#6674: [PATCH] bug#6674: " Andreas Schwab
2010-08-02 17:48 ` bug#6674: [PATCH fixed] " Óscar Fuentes
2010-08-02 19:07 ` Eli Zaretskii
2010-08-02 19:47 ` Juanma Barranquero
2010-08-02 19:57 ` Óscar Fuentes
2010-08-02 20:11 ` Juanma Barranquero
2010-08-02 20:15 ` Óscar Fuentes
2010-08-03 2:56 ` Eli Zaretskii
2010-07-20 16:46 ` bug#6674: PATCH: " Eli Zaretskii
2010-07-20 23:18 ` bug#6674: PATCH: fix assignment of grep-find-use-xargs on Windows Óscar Fuentes
2010-07-21 0:44 ` Christoph
2010-07-21 0:50 ` Juanma Barranquero
2010-07-21 0:57 ` Óscar Fuentes
2010-07-21 4:02 ` Eli Zaretskii
2010-07-21 4:05 ` Christoph
2010-08-02 2:21 ` Christoph
2010-08-02 3:10 ` Eli Zaretskii
2010-08-02 4:03 ` Christoph
2010-08-02 18:02 ` Eli Zaretskii
2010-08-02 20:17 ` bug#6674: Closing bug 6674 Óscar Fuentes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8739uxdnib.fsf_-_@telefonica.net \
--to=ofv@wanadoo.es \
--cc=6674@debbugs.gnu.org \
--cc=Juanma@debbugs.gnu.org \
--cc=cschol2112@googlemail.com \
--cc=lekktu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).