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

Bug#734939: texlive-binaries: synctex view with -x crashes consistently



Package: texlive-binaries
Version: 2013.20130729.30972-2
Severity: normal
Tags: patch

I was trying to use "synctex view" with the optional -x argument, but
already a simple "syntex view -i input -o output -x echo" segfaults.
This is caused by an missing 0 in the string passed to system
(texk/web2c/synctexdir/synctex_main.c:469).

If that is fixed, synctex segfaults later while trying to parse more
optional arguments which are not there.

The attached patch fixes both issue. Please consider applying the patch
or fixing the issues in another way.

Regards
-- 
Sebastian Ramacher
--- a/texk/web2c/synctexdir/synctex_main.c
+++ b/texk/web2c/synctexdir/synctex_main.c
@@ -304,11 +304,11 @@
 				if(++arg_index<argc) {
 					goto option_command;
 				} else {
-					synctex_view_proceed(&Ps);
+					return synctex_view_proceed(&Ps);
 				}
 			} else {
 				Ps.directory = getenv("SYNCTEX_BUILD_DIRECTORY");
-				synctex_view_proceed(&Ps);
+				return synctex_view_proceed(&Ps);
 			}
 		}
 option_command:
@@ -320,7 +320,7 @@
 					if(++arg_index<argc) {
 						goto option_hint;
 					} else {
-						synctex_view_proceed(&Ps);
+						return synctex_view_proceed(&Ps);
 					}
 				} else {
 					/* retrieve the environment variable */
@@ -329,7 +329,7 @@
 				}
 			} else {
 				Ps.viewer = getenv("SYNCTEX_VIEWER");
-				synctex_view_proceed(&Ps);
+				return synctex_view_proceed(&Ps);
 			}
 		}
 option_hint:
@@ -347,7 +347,7 @@
 						*Ps.after = '\0';
 						if(Ps.offset<strlen(Ps.middle)) {
 							++Ps.after;
-							synctex_view_proceed(&Ps);
+							return synctex_view_proceed(&Ps);
 						}
 					}
 				}
@@ -460,11 +460,12 @@
 					break;
 				}
 				/* copy the rest of viewer into the buffer */
-				if(buffer_cur != memcpy(buffer_cur,viewer,strlen(viewer))) {
+				if(buffer_cur != strncpy(buffer_cur,viewer,size)) {
 					synctex_help_view("Memory copy problem");
 					free(buffer);
 					return -1;
 				}
+				buffer[size] = '\0';
 				printf("SyncTeX: Executing\n%s\n",buffer);
 				status = system(buffer);
 				free(buffer);

Attachment: signature.asc
Description: Digital signature


Reply to: