ogajduse / rpms / texlive

Forked from rpms/texlive 6 years ago
Clone
4931932
--- texk/makeindexk/mkind.c
4931932
+++ texk/makeindexk/mkind.c	2007-02-06 13:43:26.000000000 +0100
4931932
@@ -179,7 +179,9 @@ char   *argv[];
4931932
 		    argc--;
4931932
 		    if (argc <= 0)
4931932
 			FATAL("Expected -p <num>\n","");
4931932
-		    strcpy(pageno, *++argv);
4931932
+		    if (strlen(*++argv) >= sizeof(pageno))
4931932
+			FATAL("Page number too high\n","");
4931932
+		    strcpy(pageno, *argv);
4931932
 		    init_page = TRUE;
4931932
 		    if (STREQ(pageno, EVEN)) {
4931932
 			log_given = TRUE;
4931932
@@ -227,10 +229,10 @@ char   *argv[];
4931932
 
4931932
 	if (fn_no == 0 && !sty_given)
4931932
 	{
4931932
-		char tmp[STRING_MAX + 5];
4931932
+		char tmp[STRING_MAX];
4931932
 		
4931932
 		/* base set by last call to check_idx */
4931932
-		sprintf (tmp, "%s%s", base, INDEX_STY);
4931932
+		snprintf (tmp, sizeof(tmp), "%s%s", base, INDEX_STY);
4931932
 		if (0 == access(tmp, R_OK)) {
4931932
 			open_sty (tmp);
4931932
 			sty_given = TRUE;
4931932
@@ -407,7 +409,7 @@ int     open_fn;
4931932
 
4931932
 	    if ((idx_fn = (char *) malloc(STRING_MAX)) == NULL)
4931932
 		FATAL("Not enough core...abort.\n", "");
4931932
-	    sprintf(idx_fn, "%s%s", base, INDEX_IDX);
4931932
+	    snprintf(idx_fn, STRING_MAX, "%s%s", base, INDEX_IDX);
4931932
 	    if ((open_fn && 
4931932
 	 ((idx_fp = OPEN_IN(idx_fn)) == NULL)
4931932
 	) ||
4931932
@@ -434,7 +436,7 @@ int     log_given;
4931932
 
4931932
     /* index output file */
4931932
     if (!ind_given) {
4931932
-	sprintf(ind, "%s%s", base, INDEX_IND);
4931932
+	snprintf(ind, sizeof(ind), "%s%s", base, INDEX_IND);
4931932
 	ind_fn = ind;
4931932
     }
4931932
     if ((ind_fp = OPEN_OUT(ind_fn)) == NULL)
4931932
@@ -442,14 +444,14 @@ int     log_given;
4931932
 
4931932
     /* index transcript file */
4931932
     if (!ilg_given) {
4931932
-	sprintf(ilg, "%s%s", base, INDEX_ILG);
4931932
+	snprintf(ilg, sizeof(ilg), "%s%s", base, INDEX_ILG);
4931932
 	ilg_fn = ilg;
4931932
     }
4931932
     if ((ilg_fp = OPEN_OUT(ilg_fn)) == NULL)
4931932
 	FATAL("Can't create transcript file %s.\n", ilg_fn);
4931932
 
4931932
     if (log_given) {
4931932
-	sprintf(log_fn, "%s%s", base, INDEX_LOG);
4931932
+	snprintf(log_fn, sizeof(log_fn), "%s%s", base, INDEX_LOG);
4931932
 	if ((log_fp = OPEN_IN(log_fn)) == NULL) {
4931932
 	    FATAL("Source log file %s not found.\n", log_fn);
4931932
 	} else {
4931932
@@ -505,6 +507,9 @@ char   *fn;
4931932
   if ((found = kpse_find_file (fn, kpse_ist_format, 1)) == NULL) {
4931932
      FATAL("Index style file %s not found.\n", fn);
4931932
   } else {
4931932
+    if (strlen(found) >= sizeof(sty_fn)) {
4931932
+      FATAL("Style file %s too long.\n", found);
4931932
+    }
4931932
     strcpy(sty_fn,found);
4931932
     if ((sty_fp = OPEN_IN(sty_fn)) == NULL) {
4931932
       FATAL("Could not open style file %s.\n", sty_fn);
4931932
@@ -512,6 +517,9 @@ char   *fn;
4931932
   }
4931932
 #else
4931932
     if ((path = getenv(STYLE_PATH)) == NULL) {
4931932
+        if (strlen(fn) >= sizeof(sty_fn)) {
4931932
+          FATAL("Style file %s too long.\n", fn);
4931932
+        }
4931932
 	/* style input path not defined */
4931932
 	strcpy(sty_fn, fn);
4931932
 	sty_fp = OPEN_IN(sty_fn);
4931932
--- texk/makeindexk/mkind.h
4931932
+++ texk/makeindexk/mkind.h	2007-02-06 13:42:38.000000000 +0100
4931932
@@ -322,7 +322,7 @@ ensuing.
4931932
 #ifdef LINE_MAX		/* IBM RS/6000 AIX has this in <sys/limits.h> */
4931932
 #undef LINE_MAX
4931932
 #endif
4931932
-#define LINE_MAX      72	/* maximum output line length (longer */
4931932
+#define LINE_MAX      _POSIX2_LINE_MAX	/* maximum output line length (longer */
4931932
 				/* ones wrap if possible) */
4931932
 
4931932
 #define NUMBER_MAX    16	/* maximum digits in a Roman or Arabic */
4931932
@@ -337,7 +337,7 @@ ensuing.
4931932
 #define ROMAN_MAX     16	/* maximum length of Roman page number */
4931932
 				/* field */
4931932
 
4931932
-#define STRING_MAX    256	/* maximum length of host filename */
4931932
+#define STRING_MAX    _POSIX2_LINE_MAX	/* maximum length of host filename */
4931932
 
4931932
 /*====================================================================*/
4931932