texlive[50066] Build/source/texk/kpathsea/win32: remove unused
commits+kakuto at tug.org
commits+kakuto at tug.org
Wed Feb 20 00:32:01 CET 2019
Revision: 50066
http://tug.org/svn/texlive?view=revision&revision=50066
Author: kakuto
Date: 2019-02-20 00:32:00 +0100 (Wed, 20 Feb 2019)
Log Message:
-----------
remove unused definitions
Modified Paths:
--------------
trunk/Build/source/texk/kpathsea/win32/ChangeLog
trunk/Build/source/texk/kpathsea/win32/mktexlsr.c
trunk/Build/source/texk/kpathsea/win32/mktexpk.c
trunk/Build/source/texk/kpathsea/win32/mktextfm.c
trunk/Build/source/texk/kpathsea/win32/mktexupdmain.c
Modified: trunk/Build/source/texk/kpathsea/win32/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/win32/ChangeLog 2019-02-19 22:23:52 UTC (rev 50065)
+++ trunk/Build/source/texk/kpathsea/win32/ChangeLog 2019-02-19 23:32:00 UTC (rev 50066)
@@ -1,3 +1,8 @@
+2019-02-20 Akira Kakuto <kakuto at w32tex.org>
+
+ * mktexpk.c: Remove unused definitions.
+ * mktexlsr.c, matextfm.c, mktexupdmain.c: Avoid buffer overflow.
+
2017-06-11 Akira Kakuto <kakuto at fuk.kindai.ac.jp>
* mktexfmt.c: Use fmtutil-user for consistency with other platforms.
Modified: trunk/Build/source/texk/kpathsea/win32/mktexlsr.c
===================================================================
--- trunk/Build/source/texk/kpathsea/win32/mktexlsr.c 2019-02-19 22:23:52 UTC (rev 50065)
+++ trunk/Build/source/texk/kpathsea/win32/mktexlsr.c 2019-02-19 23:32:00 UTC (rev 50066)
@@ -1,6 +1,6 @@
/* mktexlsr.c
- Copyright 2000, 2016 Akira Kakuto.
+ Copyright 2000, 2019 Akira Kakuto.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -28,6 +28,7 @@
#define HDL "%% ls-R -- filename database for kpathsea; do not change this line.\n"
#define VARTEXFONTS "c:/var/tex/fonts/ls-R"
+#define TBUF 512
FILE *ls_R;
@@ -36,7 +37,7 @@
{
DIR *dp;
struct dirent *de;
- char buff[256];
+ char buff[TBUF];
int len;
normalize (name);
@@ -103,7 +104,7 @@
int main(int ac, char **av)
{
int cdrive, tdrive;
- char ls_R_name[512];
+ char ls_R_name[TBUF];
int i, numtree;
size_t len;
char *progname;
@@ -151,6 +152,10 @@
}
for(i = 0; i < numtree; i++) {
+ if (strlen(pathbuff[i]) > (TBUF - 6)) {
+ fprintf (stderr, "Too long a directory name.\n");
+ exit (100);
+ }
strcpy(ls_R_name, pathbuff[i]);
len = strlen(ls_R_name);
if(ls_R_name[len-1] != '/') strcat(ls_R_name, "/");
Modified: trunk/Build/source/texk/kpathsea/win32/mktexpk.c
===================================================================
--- trunk/Build/source/texk/kpathsea/win32/mktexpk.c 2019-02-19 22:23:52 UTC (rev 50065)
+++ trunk/Build/source/texk/kpathsea/win32/mktexpk.c 2019-02-19 23:32:00 UTC (rev 50066)
@@ -1,6 +1,6 @@
/* mktexpk.c
- Copyright 2000, 2016 Akira Kakuto.
+ Copyright 2000, 2019 Akira Kakuto.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -49,9 +49,6 @@
#endif
#include "mktex.h"
-#define LLBUF 1024
-#define LBUF 512
-#define SBUF 512
#define TBUF 512
/*
@@ -216,10 +213,10 @@
int
main (int ac, char **av)
{
- static char execfile[SBUF];
- char rbuff[LBUF];
- char buff[LBUF];
- char cmd[LBUF];
+ static char execfile[TBUF];
+ char rbuff[TBUF];
+ char buff[TBUF];
+ char cmd[TBUF];
char mfname[TBUF];
char tfname[TBUF];
char pkname[TBUF];
@@ -230,13 +227,13 @@
char bdpi[TBUF];
char mag[TBUF];
char mode[TBUF];
- char destdir[SBUF];
+ char destdir[TBUF];
char designsize[64];
char *arg[4];
- char currdir[SBUF];
- char kpsedot[SBUF];
+ char currdir[TBUF];
+ char kpsedot[TBUF];
char *tmp;
int cdrive, tdrive;
@@ -304,7 +301,7 @@
normalize (tmp);
for (i = 0; i < 4; i++)
- arg[i] = (char *) malloc (SBUF);
+ arg[i] = (char *) malloc (TBUF);
kpse_set_program_name (av[0], NULL);
progname = kpse_program_name;
@@ -664,7 +661,7 @@
if ((p[0] == '.') && (p[1] == '/') && (issetdest != 1))
issetdest = 2;
- fpp = _getcwd (currdir, SBUF);
+ fpp = _getcwd (currdir, TBUF);
if (!fpp) {
fprintf (stderr, "Failed to get current working directory.\n");
relmem (arg);
@@ -902,7 +899,7 @@
goto do_ps2pk;
}
- while (fgets (rbuff, SBUF, fr)) {
+ while (fgets (rbuff, TBUF, fr)) {
if (rbuff[0] == '%' || rbuff[0] == '#' || rbuff[0] == '\n')
continue;
texname[0] = pfbname[0] = slant[0] = extend[0] = encname[0] = '\0';
@@ -942,10 +939,10 @@
goto do_ps2pk;
} else {
char *q;
- char a[SBUF];
- char b[SBUF];
- char psname[SBUF];
- char pscommand[SBUF];
+ char a[TBUF];
+ char b[TBUF];
+ char psname[TBUF];
+ char pscommand[TBUF];
double slantval, extendval;
texname[0] = pfbname[0] = encname[0] = '\0';
@@ -967,7 +964,7 @@
tpkerr ("Cannot open ps2pk.map to read.");
goto do_ps2pk;
}
- while ((ret=ffgets (rbuff, LBUF, fr)) != FFILE_END) {
+ while ((ret=ffgets (rbuff, TBUF, fr)) != FFILE_END) {
if(ret == BBUFF_FUL) {
fprintf(stderr, "A line in ps2pk.map seems to be too long.\n");
fprintf(stderr, "I try to continue. But something may be wrong.\n");
@@ -1289,7 +1286,7 @@
return (100);
}
- while ((i = (int)fread (rbuff, 1, LBUF, fr)))
+ while ((i = (int)fread (rbuff, 1, TBUF, fr)))
fwrite (rbuff, 1, i, fw);
fclose (fr);
Modified: trunk/Build/source/texk/kpathsea/win32/mktextfm.c
===================================================================
--- trunk/Build/source/texk/kpathsea/win32/mktextfm.c 2019-02-19 22:23:52 UTC (rev 50065)
+++ trunk/Build/source/texk/kpathsea/win32/mktextfm.c 2019-02-19 23:32:00 UTC (rev 50066)
@@ -1,6 +1,6 @@
/* mktextfm.c
- Copyright 2000, 2016 Akira Kakuto.
+ Copyright 2000, 2019 Akira Kakuto.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -25,8 +25,6 @@
#endif
#include "mktex.h"
-#define LBUF 512
-#define SBUF 512
#define TBUF 512
char *progname;
@@ -71,16 +69,16 @@
int
main (int ac, char **av)
{
- char rbuff[LBUF];
- char buff[SBUF];
- char savebuff[SBUF];
- char cmd[LBUF];
+ char rbuff[TBUF];
+ char buff[TBUF];
+ char savebuff[TBUF];
+ char cmd[TBUF];
char mffile[TBUF];
char *arg[4];
- static char execfile[SBUF];
+ static char execfile[TBUF];
- char kpsedot[SBUF];
- char currdir[SBUF];
+ char kpsedot[TBUF];
+ char currdir[TBUF];
char *tmp;
int cdrive, tdrive;
@@ -89,10 +87,10 @@
int i, savo, savi;
char *p, *fp, *fpp;
int issetdest;
- char fontname[SBUF];
+ char fontname[TBUF];
- char texbindir[512];
- char fullbin[512];
+ char texbindir[TBUF];
+ char fullbin[TBUF];
kpse_set_program_name (av[0], NULL);
progname = kpse_program_name;
@@ -159,7 +157,7 @@
}
for (i = 0; i < 4; i++)
- arg[i] = (char *) malloc (SBUF);
+ arg[i] = (char *) malloc (TBUF);
if ((!strcmp (av[1], "--destdir")) || (!strcmp (av[1], "-destdir"))) {
if (ac != 4) {
@@ -169,6 +167,10 @@
return (100);
}
issetdest = 1;
+ if (strlen(av[2]) > TBUF - 1 || strlen(av[3]) > TBUF - 1) {
+ fprintf (stderr, "Too long a string.\n");
+ return (100);
+ }
strcpy (buff, av[2]);
strcpy (fontname, av[3]);
for (p = buff; *p; p++) {
@@ -178,6 +180,10 @@
*p = '/';
}
} else {
+ if (strlen(av[1]) > TBUF - 1) {
+ fprintf (stderr, "Too long a string.\n");
+ return (100);
+ }
strcpy (fontname, av[1]);
}
@@ -209,7 +215,7 @@
return (100);
}
- fpp = _getcwd (currdir, SBUF);
+ fpp = _getcwd (currdir, TBUF);
if (!fpp) {
fprintf (stderr, "Failed to get current working directory.\n");
relmem (arg);
@@ -352,7 +358,7 @@
return (100);
}
- while ((i = (int)fread (rbuff, 1, LBUF, fr)))
+ while ((i = (int)fread (rbuff, 1, TBUF, fr)))
fwrite (rbuff, 1, i, fw);
fclose (fr);
fclose (fw);
@@ -390,7 +396,7 @@
free(tmp);
return (100);
}
- while ((i = (int)fread (rbuff, 1, LBUF, fr)))
+ while ((i = (int)fread (rbuff, 1, TBUF, fr)))
fwrite (rbuff, 1, i, fw);
fclose (fr);
fclose (fw);
Modified: trunk/Build/source/texk/kpathsea/win32/mktexupdmain.c
===================================================================
--- trunk/Build/source/texk/kpathsea/win32/mktexupdmain.c 2019-02-19 22:23:52 UTC (rev 50065)
+++ trunk/Build/source/texk/kpathsea/win32/mktexupdmain.c 2019-02-19 23:32:00 UTC (rev 50066)
@@ -1,6 +1,6 @@
/* mktexupdmain.c
- Copyright 2000, 2016 Akira Kakuto.
+ Copyright 2000, 2019 Akira Kakuto.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -19,11 +19,13 @@
#include <kpathsea/kpathsea.h>
#include "mktex.h"
+#define TBUF 512
+
int main(int argc, char **argv)
{
- char dir[256];
- char file[256];
- char path[256];
+ char dir[TBUF];
+ char file[TBUF];
+ char path[TBUF];
size_t i;
kpse_set_program_name (argv[0], NULL);
@@ -31,6 +33,10 @@
fprintf(stderr, "%s:: usage: %s DIR FILE\n", argv[0], argv[0]);
return 1;
}
+ if (strlen(argv[1]) + strlen(argv[2]) > TBUF - 2) {
+ fprintf (stderr, "Too long a string.\n");
+ exit (100);
+ }
strcpy(dir, argv[1]);
strcpy(file, argv[2]);
normalize (dir);
More information about the tex-live-commits
mailing list