[Python-checkins] python/dist/src/Lib tarfile.py,1.7,1.8

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Tue, 22 Apr 2003 15:03:16 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv5126

Modified Files:
	tarfile.py 
Log Message:
Fix by Lars Gustaebel for bug 721871: don't get upset if the prefix
field contains garbage after the first NUL character.


Index: tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** tarfile.py	11 Apr 2003 03:05:56 -0000	1.7
--- tarfile.py	22 Apr 2003 22:03:11 -0000	1.8
***************
*** 672,687 ****
          except ValueError:
              tarinfo.devmajor = tarinfo.devmajor = 0
  
          # The prefix field is used for filenames > 100 in
          # the POSIX standard.
!         # name = prefix + "/" + name
!         prefix = buf[345:500]
!         while prefix and prefix[-1] == NUL:
!             prefix = prefix[:-1]
!         if len(prefix.split(NUL)) == 1:
!             tarinfo.prefix = prefix
!             tarinfo.name = normpath(os.path.join(tarinfo.prefix, tarinfo.name))
!         else:
!             tarinfo.prefix = buf[345:500]
  
          # Directory names should have a '/' at the end.
--- 672,682 ----
          except ValueError:
              tarinfo.devmajor = tarinfo.devmajor = 0
+         tarinfo.prefix = buf[345:500]
  
          # The prefix field is used for filenames > 100 in
          # the POSIX standard.
!         # name = prefix + '/' + name
!         if tarinfo.type != GNUTYPE_SPARSE:
!             tarinfo.name = normpath(os.path.join(nts(tarinfo.prefix), tarinfo.name))
  
          # Directory names should have a '/' at the end.