From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?=C3=93scar?= Fuentes Newsgroups: gmane.emacs.bugs 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 Message-ID: <8739uxdnib.fsf_-_@telefonica.net> References: <878w564xtc.fsf@telefonica.net> <87vd8a2rxg.fsf@telefonica.net> <87r5iy2ptw.fsf@telefonica.net> <83vd8acbbv.fsf@gnu.org> <87eiey2apg.fsf@telefonica.net> <4C569D60.5040804@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1280766651 5984 80.91.229.12 (2 Aug 2010 16:30:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 2 Aug 2010 16:30:51 +0000 (UTC) Cc: Christoph , Juanma@debbugs.gnu.org, Barranquero To: 6674@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 02 18:30:49 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OfxuY-0005Tb-RQ for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Aug 2010 18:30:47 +0200 Original-Received: from localhost ([127.0.0.1]:35222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfxuX-0005nC-LR for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Aug 2010 12:30:45 -0400 Original-Received: from [140.186.70.92] (port=58250 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfxYo-0003jr-BA for bug-gnu-emacs@gnu.org; Mon, 02 Aug 2010 12:08:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OfxYi-00014Q-7G for bug-gnu-emacs@gnu.org; Mon, 02 Aug 2010 12:08:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56893) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfxYi-00014M-5L for bug-gnu-emacs@gnu.org; Mon, 02 Aug 2010 12:08:12 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OfxFB-000682-Jz; Mon, 02 Aug 2010 11:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Aug 2010 15:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6674 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6674-submit@debbugs.gnu.org id=B6674.128076407523550 (code B ref 6674); Mon, 02 Aug 2010 15:48:01 +0000 Original-Received: (at 6674) by debbugs.gnu.org; 2 Aug 2010 15:47:55 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfxF4-00067n-TK for submit@debbugs.gnu.org; Mon, 02 Aug 2010 11:47:55 -0400 Original-Received: from impaqm4.telefonica.net ([213.4.138.4]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfxF2-00067i-0h for 6674@debbugs.gnu.org; Mon, 02 Aug 2010 11:47:53 -0400 Original-Received: from IMPmailhost2.adm.correo ([10.20.102.39]) by IMPaqm4.telefonica.net with bizsmtp id pT0M1e00H0r0BT63QToE6q; Mon, 02 Aug 2010 17:48:14 +0200 Original-Received: from qcore ([83.42.13.171]) by IMPmailhost2.adm.correo with BIZ IMP id pToC1e00W3hRxRf1iToDup; Mon, 02 Aug 2010 17:48:14 +0200 X-Brightmail-Tracker: AAAAAA== X-TE-authinfo: authemail="981711563$telefonica.net" |auth_email="981711563@telefonica.net" X-TE-AcuTerraCos: auth_cuTerraCos="cosuitnetc01" In-Reply-To: <4C569D60.5040804@gmail.com> ("Laimonas =?UTF-8?Q?V=C4=97bra"'s?= message of "Mon, 02 Aug 2010 13:26:40 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 02 Aug 2010 11:48:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:39160 Archived-At: Laimonas V=C4=97bra writes: > Isn't it wsprintf (used in cmdproxy.c to quote args and for other purpose= s): > http://msdn.microsoft.com/en-us/library/ms647550(VS.85).aspx > > that imposes 1024 buffer/string length limit...? 2010-08-02 =C3=93scar Fuentes * 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 . */ #include /* getenv */ #include /* strlen */ =20 +/* 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, ...); =20 /******* Mock C library routines *********************************/ =20 @@ -604,6 +607,7 @@ main (int argc, char ** argv) { char * p; int extra_arg_space =3D 0; + int maxlen, remlen; int run_command_dot_com; =20 progname =3D 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). */ =20 - buf =3D p =3D alloca (strlen (progname) + extra_arg_space + - strlen (cmdline) + 16); + remlen =3D maxlen =3D + strlen (progname) + extra_arg_space + strlen (cmdline) + 16; + buf =3D p =3D alloca (maxlen + 1); =20 /* Quote progname in case it contains spaces. */ - p +=3D wsprintf (p, "\"%s\"", progname); + p +=3D _snprintf (p, remlen, "\"%s\"", progname); + remlen =3D maxlen - (p - buf); =20 /* Include pass_through_args verbatim; these are just switches so should not need quoting. */ for (argv =3D pass_through_args; *argv !=3D NULL; ++argv) - p +=3D wsprintf (p, " %s", *argv); + { + p +=3D _snprintf (p, remlen, " %s", *argv); + remlen =3D maxlen - (p - buf); + } =20 if (run_command_dot_com) - wsprintf(p, " /e:%d /c %s", envsize, cmdline); + { + _snprintf(p, remlen, " /e:%d /c %s", envsize, cmdline); + remlen =3D maxlen - (p - buf); + } else - wsprintf(p, " /c %s", cmdline); + { + _snprintf(p, remlen, " /c %s", cmdline); + remlen =3D maxlen - (p - buf); + } cmdline =3D buf; } else @@ -669,19 +684,27 @@ main (int argc, char ** argv) else path[0] =3D '\0'; =20 - cmdline =3D p =3D alloca (strlen (progname) + extra_arg_space + - strlen (path) + 13); + remlen =3D maxlen =3D + strlen (progname) + extra_arg_space + strlen (path) + 13; + cmdline =3D p =3D alloca (maxlen + 1); =20 /* Quote progname in case it contains spaces. */ - p +=3D wsprintf (p, "\"%s\" %s", progname, path); + p +=3D _snprintf (p, remlen, "\"%s\" %s", progname, path); + remlen =3D maxlen - (p - cmdline); =20 /* Include pass_through_args verbatim; these are just switches so should not need quoting. */ for (argv =3D pass_through_args; *argv !=3D NULL; ++argv) - p +=3D wsprintf (p, " %s", *argv); + { + p +=3D _snprintf (p, remlen, " %s", *argv); + remlen =3D maxlen - (p - cmdline); + } =20 if (run_command_dot_com) - wsprintf (p, " /e:%d", envsize); + { + _snprintf (p, remlen, " /e:%d", envsize); + remlen =3D maxlen - (p - cmdline); + } } } =20