File TeX-Guy-buffer-overflow-strncat.patch of Package TeX-Guy
Index: TeX-Guy-1.3.2/DVIlib2-2.9.1/dvipages.c
===================================================================
--- TeX-Guy-1.3.2.orig/DVIlib2-2.9.1/dvipages.c
+++ TeX-Guy-1.3.2/DVIlib2-2.9.1/dvipages.c
@@ -84,12 +84,12 @@ main(int argc, char **argv)
if (param_dpi > 0){
snprintf(tmp, sizeof(tmp),
", %s=%d", PARAM_NAME_DPI, param_dpi);
- strncat(params, tmp, sizeof(params));
+ strncat(params, tmp, sizeof(params)-strlen(params)-1);
}
if (param_kpathsea_mode != NULL){
snprintf(tmp, sizeof(tmp),
", %s=%s", PARAM_NAME_MODE, param_kpathsea_mode);
- strncat(params, tmp, sizeof(params));
+ strncat(params, tmp, sizeof(params)-strlen(params)-1);
}
if (DVI_INIT(param_vflibcap, NULL) < 0){
Index: TeX-Guy-1.3.2/DVIlib2-2.9.1/spc_ps.c
===================================================================
--- TeX-Guy-1.3.2.orig/DVIlib2-2.9.1/spc_ps.c
+++ TeX-Guy-1.3.2/DVIlib2-2.9.1/spc_ps.c
@@ -893,8 +893,8 @@ eps2psfile(DVI dvi, DVI_DEVICE dev,
strncpy(ps_path, dvi_path, sizeof(ps_path));
p = strrchr(ps_path, '/');
*p = '\0';
- strncat(ps_path, "/", sizeof(ps_path));
- strncat(ps_path, psi->param_filename, sizeof(ps_path));
+ strncat(ps_path, "/", sizeof(ps_path)-strlen(ps_path)-1);
+ strncat(ps_path, psi->param_filename, sizeof(ps_path)-strlen(ps_path)-1);
}
if ((fp_in = fopen(ps_path, FOPEN_RD_MODE_TEXT)) == NULL){
if ((fp_in = fopen(psi->param_filename, FOPEN_RD_MODE_TEXT)) == NULL){
@@ -2160,19 +2160,19 @@ gs_convert_to_bitmap(DVI dvi, DVI_DEVICE
"quit.ps");
#if 0
strncpy(gs_cmd, "", sizeof(gs_cmd));
- strncat(gs_cmd, DEV_CALL(dev,gs_program_path)(dev, dvi), sizeof(gs_cmd));
- strncat(gs_cmd, " -dQUIET", sizeof(gs_cmd));
- strncat(gs_cmd, " -dNOPAUSE", sizeof(gs_cmd));
- strncat(gs_cmd, " ", sizeof(gs_cmd));
- strncat(gs_cmd, OptFormat, sizeof(gs_cmd));
- strncat(gs_cmd, " ", sizeof(gs_cmd));
- strncat(gs_cmd, OptBitmapSize, sizeof(gs_cmd));
- strncat(gs_cmd, " ", sizeof(gs_cmd));
- strncat(gs_cmd, OptOutput, sizeof(gs_cmd));
- strncat(gs_cmd, " ", sizeof(gs_cmd));
- strncat(gs_cmd, psfile, sizeof(gs_cmd));
- strncat(gs_cmd, " ", sizeof(gs_cmd));
- strncat(gs_cmd, "quit.ps", sizeof(gs_cmd));
+ strncat(gs_cmd, DEV_CALL(dev,gs_program_path)(dev, dvi), sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " -dQUIET", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " -dNOPAUSE", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " ", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, OptFormat, sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " ", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, OptBitmapSize, sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " ", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, OptOutput, sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " ", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, psfile, sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, " ", sizeof(gs_cmd)-strlen(gs_cmd)-1);
+ strncat(gs_cmd, "quit.ps", sizeof(gs_cmd)-strlen(gs_cmd)-1);
#endif
if (getenv("DVILIB_DEBUG_EPS") != NULL){