linville pushed to unzoo (f22). "One more round of strncat adjustments..."

notifications at fedoraproject.org notifications at fedoraproject.org
Mon Mar 30 21:40:41 UTC 2015


>From d4edbeb993ed90ddfbf1e5621866aaebd86624af Mon Sep 17 00:00:00 2001
From: "John W. Linville" <linville at tuxdriver.com>
Date: Mon, 30 Mar 2015 16:44:57 -0400
Subject: One more round of strncat adjustments...


diff --git a/unzoo-convert-strcpy_strcat-to-strncpy_strncat.patch b/unzoo-convert-strcpy_strcat-to-strncpy_strncat.patch
index a352f21..50b2ee9 100644
--- a/unzoo-convert-strcpy_strcat-to-strncpy_strncat.patch
+++ b/unzoo-convert-strcpy_strcat-to-strncpy_strncat.patch
@@ -1,6 +1,6 @@
-diff -up unzoo-4.4/unzoo.c.orig unzoo-4.4/unzoo.c
---- unzoo-4.4/unzoo.c.orig	2015-03-30 13:54:26.830442154 -0400
-+++ unzoo-4.4/unzoo.c	2015-03-30 13:54:29.636472741 -0400
+diff -up unzoo-4.4/unzoo.c.strncpy unzoo-4.4/unzoo.c
+--- unzoo-4.4/unzoo.c.strncpy	2014-07-16 15:15:24.328480269 -0400
++++ unzoo-4.4/unzoo.c	2015-03-30 16:40:47.728880500 -0400
 @@ -247,6 +247,7 @@
  *H
  */
@@ -29,7 +29,7 @@ diff -up unzoo-4.4/unzoo.c.orig unzoo-4.4/unzoo.c
  #endif
  #ifdef  SYS_IS_VMS
  #define CONV_NAME(naml,namu)    ConvName( (naml), (namu), 39L, 39L, '_' )
-@@ -1224,9 +1225,9 @@ int             MakeDirs ( pre, patu )
+@@ -1224,9 +1225,13 @@ int             MakeDirs ( pre, patu )
          *d = '\0';  *n = '\0';
          CONV_DIRE( dirl, diru );
          CONV_NAME( naml, namu );
@@ -37,25 +37,32 @@ diff -up unzoo-4.4/unzoo.c.orig unzoo-4.4/unzoo.c
 -        strcat( patl, dirl );
 -        strcat( patl, naml );
 +        strncpy( patl, pre,  sizeof(patl) - 1 );
-+        strncat( patl, dirl, sizeof(patl) - 1 );
-+        strncat( patl, naml, sizeof(patl) - 1 );
++        if ( sizeof(patl) - strnlen( patl, sizeof(patl) ) >
++             strnlen( dirl, sizeof( dirl ) ) + 1)
++            strncat( patl, dirl, sizeof( dirl ) );
++        if ( sizeof(patl) - strnlen( patl, sizeof(patl) ) >
++             strnlen( naml, sizeof( naml ) ) + 1)
++            strncat( patl, naml, sizeof(naml) );
          /*N 1993/11/03 martin what should I do with the return code?       */
          /*N 1993/11/03 martin it could be 0 if the directory exists!       */
          MAKE_DIRE( patl );
-@@ -1583,14 +1584,15 @@ int             EntrReadArch ()
+@@ -1583,14 +1588,17 @@ int             EntrReadArch ()
          CONV_NAME( Entry.naml, (Entry.lnamu ? Entry.namu : Entry.nams) );
      }
      else {
 -        strcpy( Entry.dirl, Entry.diru );
 -        strcpy( Entry.naml, (Entry.lnamu ? Entry.namu : Entry.nams) );
+-    }
+-    strcpy( Entry.patl, Entry.dirl );
+-    strcat( Entry.patl, Entry.naml );
 +        strncpy( Entry.dirl, Entry.diru, sizeof(Entry.dirl) - 1 );
 +        strncpy( Entry.naml, (Entry.lnamu ? Entry.namu : Entry.nams),
 +	         sizeof(Entry.naml) - 1 );
-     }
--    strcpy( Entry.patl, Entry.dirl );
--    strcat( Entry.patl, Entry.naml );
++    }
 +    strncpy( Entry.patl, Entry.dirl, sizeof(Entry.patl) - 1 );
-+    strncat( Entry.patl, Entry.naml, sizeof(Entry.patl) - 1 );
++    if ( sizeof( Entry.patl) - strnlen( Entry.patl, sizeof( Entry.patl ) ) >
++         strnlen( Entry.naml, sizeof( Entry.naml ) ) + 1 )
++        strncat( Entry.patl, Entry.naml, sizeof( Entry.naml ) );
  
      /* create the name with the version appended                           */
 -    strcpy( Entry.patv, Entry.patl );
@@ -63,33 +70,37 @@ diff -up unzoo-4.4/unzoo.c.orig unzoo-4.4/unzoo.c
      p = Entry.patv;  while ( *p != '\0' )  p++;
      *p++ = ';';
      for ( l = 10000; 0 < l; l /= 10 )
-@@ -2349,7 +2351,8 @@ int             ListArch ( ver, arc, fil
+@@ -2349,7 +2357,9 @@ int             ListArch ( ver, arc, fil
      unsigned long       i;              /* loop variable                   */
  
      /* try to open the archive under various names                         */
 -    strcpy(arczoo,arc);  strcat(arczoo,".zoo");
 +    strncpy(arczoo,arc,sizeof(arczoo)-1);
-+    strncat(arczoo,".zoo",sizeof(arczoo)-1);
++    if (sizeof(arczoo) - strnlen(arczoo, sizeof(arczoo)) > 5)
++    	strncat(arczoo,".zoo",4);
      if ( OpenReadArch(arc) ) {
          if ( ! DescReadArch() ) {
              ClosReadArch();
-@@ -2504,7 +2507,8 @@ int             ExtrArch ( bim, out, ovr
+@@ -2504,7 +2514,9 @@ int             ExtrArch ( bim, out, ovr
      unsigned long       i;              /* loop variable                   */
  
      /* try to open the archive under various names                         */
 -    strcpy(arczoo,arc);  strcat(arczoo,".zoo");
 +    strncpy(arczoo,arc,sizeof(arczoo)-1);
-+    strncat(arczoo,".zoo",sizeof(arczoo)-1);
++    if (sizeof(arczoo) - strnlen(arczoo, sizeof(arczoo)) > 5)
++    	strncat(arczoo,".zoo",4);
      if ( OpenReadArch(arc) ) {
          if ( ! DescReadArch() ) {
              ClosReadArch();
-@@ -2577,7 +2581,8 @@ int             ExtrArch ( bim, out, ovr
+@@ -2577,7 +2589,10 @@ int             ExtrArch ( bim, out, ovr
          }
  
          /* check that such a file does not already exist                   */
 -        strcpy( patl, pre );  strcat( patl, Entry.patl );
-+        strncpy( patl, pre, sizeof(patl) - 1 );
-+        strncat( patl, Entry.patl, sizeof(patl) - 1 );
++        strncpy( patl, pre, sizeof( patl ) - 1 );
++        if ( sizeof(patl) - strnlen( patl, sizeof(patl) ) >
++             strnlen( Entry.patl, sizeof( Entry.patl ) ) + 1)
++            strncat( patl, Entry.patl, sizeof( Entry.patl ) );
          if ( out == 2 && ovr == 0 && OpenReadFile(patl,0L) ) {
              ClosReadFile();
              do {
diff --git a/unzoo.spec b/unzoo.spec
index b1bcbca..eef218a 100644
--- a/unzoo.spec
+++ b/unzoo.spec
@@ -1,6 +1,6 @@
 Name:           unzoo
 Version:        4.4
-Release:        14%{?dist}
+Release:        15%{?dist}
 Summary:        ZOO archive extractor
 
 Group:          Applications/Archiving
@@ -55,6 +55,9 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Mon Mar 30 2015 John W. Linville <linville at redhat.com> - 4.4-15
+- One more round of strncat adjustments...
+
 * Mon Mar 30 2015 John W. Linville <linville at redhat.com> - 4.4-14
 - Fix the compiler warning patch...
 
-- 
cgit v0.10.2


	http://pkgs.fedoraproject.org/cgit/unzoo.git/commit/?h=f22&id=d4edbeb993ed90ddfbf1e5621866aaebd86624af


More information about the scm-commits mailing list