Skip to contentSkip to conversation

strncpy misuse in ufs.c]

PATCH In review Lubomir Kundrak 2 participants 3 messages Apr 11, 2006 – Apr 12, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 strncpy misuse in ufs.c]

Now again, to correct list.
Below is the little fix for fs/ufs.c

ufs.c 2006-04-10 12:17:32.000000000 +0200 renamed from ufs.c.orig 2006-04-10 12:17:10.000000000 +0200 +1 -1
@@ -400,7 +400,7 @@
   unsigned int pos = 0;
   int dirino;
 
-  grub_strncpy (fpath, path, grub_strlen (path));
+  grub_strncpy (fpath, path, grub_strlen (path)+1);
 
   /* Skip the first slash.  */
   if (name[0] == '/')

regards,
lubo

Signature · 3 lines
  o	Lubomir Kundrak
 *O*	<[email protected]>, http://skosi.org/~lkundrak/
 (_)	SKOSI -- Slovak OpenSource Initiative
#1 lore raw

EEh.... should actually read

ufs.c 2006-04-10 12:17:32.000000000 +0200 renamed from ufs.c.orig 2006-04-10 12:17:10.000000000 +0200 +1 -1
@@ -400,7 +400,7 @@
   unsigned int pos = 0;
   int dirino;
 
-  grub_strncpy (fpath, path, grub_strlen (path));
+  grub_strncpy (fpath, path, sizeof (fpath)+);
 
   /* Skip the first slash.  */
   if (name[0] == '/')
Quoted 51 lines · Lubomir Kundrak

X-Original-To: [email protected]
Delivered-To: [email protected]
Date: Tue, 11 Apr 2006 14:08:22 +0200
From: Lubomir Kundrak <[email protected]>
To: [email protected]
Mail-Followup-To: Lubomir Kundrak <[email protected]>, [email protected]
User-Agent: Mutt/1.4.2.1i
Subject: [patch] strncpy misuse in ufs.c]
X-BeenThere: [email protected]
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: The development of GRUB 2 <[email protected]>
List-Id: The development of GRUB 2 <grub-devel.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/grub-devel>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/grub-devel>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/grub-devel>,
<mailto:[email protected]?subject=subscribe>
Errors-To: [email protected]

Now again, to correct list.
Below is the little fix for fs/ufs.c

ufs.c 2006-04-10 12:17:32.000000000 +0200 renamed from ufs.c.orig 2006-04-10 12:17:10.000000000 +0200 +1 -1
@@ -400,7 +400,7 @@
   unsigned int pos = 0;
   int dirino;
 
-  grub_strncpy (fpath, path, grub_strlen (path));
+  grub_strncpy (fpath, path, grub_strlen (path)+1);
 
   /* Skip the first slash.  */
   if (name[0] == '/')

regards,
lubo

Signature · 10 lines
  o	Lubomir Kundrak
 *O*	<[email protected]>, http://skosi.org/~lkundrak/
 (_)	SKOSI -- Slovak OpenSource Initiative



_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 3 lines
  o	Lubomir Kundrak
 *O*	<[email protected]>, http://skosi.org/~lkundrak/
 (_)	SKOSI -- Slovak OpenSource Initiative
#2 lore raw

ufs.c 2006-04-10 12:17:32.000000000 +0200 line 403

Quoted 10 lines · Lubomir Kundrak

EEh.... should actually read

ufs.c 2006-04-10 12:17:32.000000000 +0200 renamed from ufs.c.orig 2006-04-10 12:17:10.000000000 +0200 +1 -1
@@ -400,7 +400,7 @@
   unsigned int pos = 0;
   int dirino;
 
-  grub_strncpy (fpath, path, grub_strlen (path));
+  grub_strncpy (fpath, path, sizeof (fpath)+);

Why the floating plus? Isn't this wrong?

Can you please explain what the patch exactly fixes and why the current code is wrong? Also, please submit a changelog entry.

--
Marco