🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #6

bug in GNU fileutils-3.3 cp, make_path and re_protect

#6
From: Rick Sladkey
Date: Wed, 28 Oct 1992 05:35
33 lines
1677 bytes
When using --path with cp from GNU fileutils-3.3, cp sometimes fails
to correctly make leading pathname components because not enough space
is allocated for the trailing null byte before doing a string copy.

Here is a patch.
-----
--- fileutils-3.3/src/cp.c.orig	Fri Jul 17 02:02:32 1992
+++ fileutils-3.3/src/cp.c	Wed Oct 28 00:13:39 1992
@@ -812,13 +812,13 @@
   char *tmp_dst_dirname;	/* Leading path of `dirpath', malloc. */
   char *dst_dirname;		/* Leading path of `dirpath', alloca. */
 
-  dirpath = alloca (strlen (const_dirpath));
+  dirpath = alloca (strlen (const_dirpath) + 1);
   strcpy (dirpath, const_dirpath);
 
   src = dirpath + src_offset;
 
   tmp_dst_dirname = dirname (dirpath); 
-  dst_dirname = alloca (strlen (tmp_dst_dirname));
+  dst_dirname = alloca (strlen (tmp_dst_dirname) + 1);
   strcpy (dst_dirname, tmp_dst_dirname);
   free (tmp_dst_dirname);
 
@@ -931,7 +931,7 @@
   char *dst_path;		/* A copy of CONST_DST_PATH we can change. */
   char *src_path;		/* The source name in `dst_path'. */
 
-  dst_path = alloca (strlen (const_dst_path));
+  dst_path = alloca (strlen (const_dst_path) + 1);
   strcpy (dst_path, const_dst_path);
   src_path = dst_path + src_offset; 
 
Technical Details
Message-ID: <921028.003546.jrs@lepton>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!world.std.com!jrs

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!world.std.com!jrs
From: jrs@world.std.com (Rick Sladkey)
Subject: bug in GNU fileutils-3.3 cp, make_path and re_protect
Message-ID: <921028.003546.jrs@lepton>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 28 Oct 1992 05:35:46 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 34