emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r99961: nt/cmdproxy.c (main): Use


From: Juanma Barranquero
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r99961: nt/cmdproxy.c (main): Use _snprintf instead of wsprintf (bug#6647).
Date: Mon, 02 Aug 2010 21:35:28 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99961
author: Óscar Fuentes <address@hidden>
committer: Juanma Barranquero <address@hidden>
branch nick: emacs-23
timestamp: Mon 2010-08-02 21:35:28 +0200
message:
  nt/cmdproxy.c (main): Use _snprintf instead of wsprintf (bug#6647).
modified:
  nt/ChangeLog
  nt/cmdproxy.c
=== modified file 'nt/ChangeLog'
--- a/nt/ChangeLog      2010-05-08 03:28:26 +0000
+++ b/nt/ChangeLog      2010-08-02 19:35:28 +0000
@@ -1,3 +1,8 @@
+2010-08-02  Óscar Fuentes  <address@hidden>
+
+       * cmdproxy.c (main): Use _snprintf instead of wsprintf,
+       which has a 1024 char limit on Windows (bug#6647).
+
 2010-05-07  Chong Yidong  <address@hidden>
 
        * Version 23.2 released.

=== modified file 'nt/cmdproxy.c'
--- a/nt/cmdproxy.c     2010-01-13 08:35:10 +0000
+++ b/nt/cmdproxy.c     2010-08-02 19:35:28 +0000
@@ -35,6 +35,9 @@
 #include <stdlib.h>  /* getenv */
 #include <string.h>  /* strlen */
 
+/* We don't want to include stdio.h because we are already duplicating
+   lots of it here */
+extern int _snprintf (char *buffer, size_t count, const char *format, ...);
 
 /*******  Mock C library routines  *********************************/
 
@@ -604,6 +607,7 @@
     {
       char * p;
       int    extra_arg_space = 0;
+      int    maxlen, remlen;
       int    run_command_dot_com;
 
       progname = getenv ("COMSPEC");
@@ -635,21 +639,27 @@
             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);
          else
-           wsprintf(p, " /c %s", cmdline);
+           _snprintf (p, remlen, " /c %s", cmdline);
+         remlen = maxlen - (p - buf);
          cmdline = buf;
        }
       else
@@ -669,19 +679,27 @@
          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);
+           }
        }
     }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]