rsync-2.5.1pre1 with -F option

Jos Backus josb at cncdsl.com
Thu Dec 6 13:00:35 EST 2001


> Program received signal SIGSEGV, Segmentation fault.
> write_batch_argvs_file (orig_argc=-2, argc=0, argv=0x0) at batch.c:153
> 153            if ( !strcmp(argv[i],"-F") ){  /* safer to change it here 
> than script*/

I'm not proud of this fix, but at least it makes -F/--write-batch work
properly:

Index: batch.c
===================================================================
RCS file: /cvsroot/rsync/batch.c,v
retrieving revision 1.6
diff -u -r1.6 batch.c
--- batch.c	2 Dec 2001 22:47:30 -0000	1.6
+++ batch.c	6 Dec 2001 02:00:05 -0000
@@ -150,12 +150,17 @@
 	/* Write argvs info to batch file */
 
 	for (i = argc - orig_argc; i < argc; i++) {
-		/* FIXME: This apparently crashes if rsync is run with
-		 * just "rsync -F".  I think directly manipulating
-		 * argv[] is probably bogus -- what if -F is part of a
-		 * run of several short options? */
-		if (!strcmp(argv[i], "-F")) {	/* safer to change it here than script */
-			strncat(buff, "-f ", 3);	/* chg to -f + ext to get ready for remote */
+		/*
+		 * FIXME:
+		 * I think directly manipulating argv[] is probably
+		 * bogus -- what if -F is part of a run of several short
+		 * options?
+		 */
+		if (!strcmp(argv[i], "-F") ||
+		    !strcmp(argv[i], "--write-batch")) {
+			/* safer to change it here than script */
+			/* chg to -f + ext to get ready for remote */
+			strncat(buff, "-f ", 3);
 			strncat(buff, batch_file_ext,
 				strlen(batch_file_ext));
 		} else {
Index: main.c
===================================================================
RCS file: /cvsroot/rsync/main.c,v
retrieving revision 1.134
diff -u -r1.134 main.c
--- main.c	15 Aug 2001 07:50:07 -0000	1.134
+++ main.c	6 Dec 2001 02:00:05 -0000
@@ -765,8 +765,10 @@
 	extern int write_batch;  /*  dw */
 	extern char *batch_ext;   /*  dw */
 	int orig_argc;  /* dw */
+	char **orig_argv;
 
 	orig_argc = argc;   /* dw */
+	orig_argv = argv;
 
 	signal(SIGUSR1, sigusr1_handler);
 	signal(SIGUSR2, sigusr2_handler);
@@ -806,7 +808,7 @@
 
 	if (write_batch) { /* dw */
 	    create_batch_file_ext();
-	    write_batch_argvs_file(orig_argc, argc, argv);
+	    write_batch_argvs_file(orig_argc, argc, orig_argv + argc + 1);
 	}
 
 	if (read_batch) { /* dw */

-- 
Jos Backus                 _/  _/_/_/        Santa Clara, CA
                          _/  _/   _/
                         _/  _/_/_/             
                    _/  _/  _/    _/
josb at cncdsl.com     _/_/   _/_/_/            use Std::Disclaimer;




More information about the rsync mailing list