texlive[53495] Build/source/texk/dvipdfm-x: Correct wrong sizes of

commits+kakuto at tug.org commits+kakuto at tug.org
Wed Jan 22 16:30:12 CET 2020


Revision: 53495
          http://tug.org/svn/texlive?view=revision&revision=53495
Author:   kakuto
Date:     2020-01-22 16:30:12 +0100 (Wed, 22 Jan 2020)
Log Message:
-----------
Correct wrong sizes of opassword and upassword

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/dvi.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-01-22 02:12:35 UTC (rev 53494)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-01-22 15:30:12 UTC (rev 53495)
@@ -1,3 +1,8 @@
+2020-01-22  Akira Kakuto  <kakuto at w32tex.org>
+
+	* dvi.c: Correct wrong sizes of opassword and upassword
+	in scan_special_encrypt().
+
 2020-01-16  Karl Berry  <karl at freefriends.org>
 
 	* xbb.c (show_version),

Modified: trunk/Build/source/texk/dvipdfm-x/dvi.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/dvi.c	2020-01-22 02:12:35 UTC (rev 53494)
+++ trunk/Build/source/texk/dvipdfm-x/dvi.c	2020-01-22 15:30:12 UTC (rev 53495)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2019 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
 
     Copyright (C) 2012-2015 by Khaled Hosny <khaledhosny at eglug.org>
@@ -2259,6 +2259,8 @@
   return  error;
 }
 
+#include "pdfencrypt.h"
+
 static int
 scan_special_encrypt (int *key_bits, int32_t *permission, char *opassword, char *upassword,
                       const char **curptr, const char *endptr)
@@ -2279,15 +2281,21 @@
       skip_white(&p, endptr);
       if (!strcmp(kp, "ownerpw")) {
         if ((obj = parse_pdf_string(&p, endptr))) {
-          if (pdf_string_value(obj))
-            strncpy(opassword, pdf_string_value(obj), sizeof(opassword)-1);
+          if (pdf_string_value(obj)) {
+            int str_length = (MAX_PWD_LEN - 1 > pdf_string_length(obj)
+                ? pdf_string_length(obj) : MAX_PWD_LEN - 1);
+            strncpy(opassword, pdf_string_value(obj), str_length);
+          }
           pdf_release_obj(obj);
         } else
           error = -1;
       } else if (!strcmp(kp, "userpw")) {
         if ((obj = parse_pdf_string(&p, endptr))) {
-          if (pdf_string_value(obj))
-            strncpy(upassword, pdf_string_value(obj), sizeof(upassword)-1);
+          if (pdf_string_value(obj)) {
+            int str_length = (MAX_PWD_LEN - 1 > pdf_string_length(obj)
+                ? pdf_string_length(obj) : MAX_PWD_LEN - 1);
+            strncpy(upassword, pdf_string_value(obj), str_length);
+          }
           pdf_release_obj(obj);
         } else
           error = -1;



More information about the tex-live-commits mailing list