🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1070

Bug in tar-1.11?

#1070
From: andrew morton
Date: Wed, 11 Nov 1992 15:08
26 lines
1435 bytes
In tar-1.11, extract.c, line 343 or thereabouts, we have


			 /*
			  * Kludge alert.  NAME is assigned to header.name
			  * because during the extraction, the space that
			  * contains the header will get scribbled on, and
			  * the name will get munged, so any error messages
			  * that happen to contain the filename will look
			  * REAL interesting unless we do this.
			  */
			 namelen = strlen(skipcrud + current_file_name);
			 name = (char *) malloc((sizeof(char)) * namelen);
			 bcopy(skipcrud+current_file_name, name, namelen);
			 size = hstat.st_size;
			 extract_sparse_file(fd, &size, hstat.st_size, name);

Is it not the case that 'name' is not null-terminated?
Don't we want:

			 namelen = strlen(skipcrud + current_file_name);
			 name = (char *) malloc((sizeof(char)) * (namelen + 1));
			 bcopy(skipcrud+current_file_name, name, namelen);
			name[namelen] = '\0';
			 size = hstat.st_size;
			 extract_sparse_file(fd, &size, hstat.st_size, name);
Technical Details
Message-ID: <199211102308.AA13985@wampyr.cc.uow.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cc.uow.EDU.AU!amorton

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cc.uow.EDU.AU!amorton
From: amorton@cc.uow.EDU.AU (andrew morton)
Subject: Bug in tar-1.11?
Message-ID: <199211102308.AA13985@wampyr.cc.uow.edu.au>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 11 Nov 1992 15:08:52 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 28