Skip to contentSkip to conversation

bug fixed on grub_strncat()

PATCH zhanghuan 2 participants 2 messages Mar 20, 2008 – Apr 13, 2008

lore
Share & tools
lore

zhanghuan

author
#0 lore raw

grub_strncat() eats the last char copid from 'dest', this patch should fix it.

kern/misc.c 2008-03-20 10:39:36.000000000 +0800 renamed from kern/misc.c 2008-02-03 21:11:31.000000000 +0800 +2 -1
diff -ur grub-1.96/kern/misc.c grub-1.96fix/kern/misc.c
@@ -110,7 +110,8 @@
 
   while ((*p++ = *src++) != '\0' && --c)
     ;
-  *(--p) = '\0';
+  if (!c)
+    *(p) = '\0';
 
 
 

PS: no body cares about previous patch I sent??
I put it below, it is easy to understand when you read it.

kern/env.c +1 -1
diff -ur grub-1.96/kern/env.c grub-1.96fix/kern/env.c
@@ -124,7 +124,7 @@
     {
       struct grub_env_var *p, *q;
       
-      for (p = current_context->prev->vars[i]; p; p = q)
+      for (p = current_context->vars[i]; p; p = q)
 	{
 	  q = p->next;
 	  grub_free (p);

Zhang Huan
Tel: (86)10-6260-0549
Mailing: P. O. Box 2704# Beijing
Postcode: 100080
National Research Centre for High Performance Computers Institute of Computing Technology, Chinese Academy of Sciences No. 6, South Kexueyuan Road, Haidian District Beijing, China

#1 lore raw

Both fixed, thank you!

Quoted 49 lines · zhanghuan

grub_strncat() eats the last char copid from 'dest', this patch should fix it.

diff -ur grub-1.96/kern/misc.c grub-1.96fix/kern/misc.c

kern/misc.c 2008-03-20 10:39:36.000000000 +0800 renamed from kern/misc.c 2008-02-03 21:11:31.000000000 +0800 +2 -1
@@ -110,7 +110,8 @@
 
   while ((*p++ = *src++) != '\0' && --c)
     ;
-  *(--p) = '\0';
+  if (!c)
+    *(p) = '\0';
 
 
 

PS: no body cares about previous patch I sent??
I put it below, it is easy to understand when you read it.

diff -ur grub-1.96/kern/env.c grub-1.96fix/kern/env.c

kern/env.c +1 -1
@@ -124,7 +124,7 @@
     {
       struct grub_env_var *p, *q;
 
-      for (p = current_context->prev->vars[i]; p; p = q)
+      for (p = current_context->vars[i]; p; p = q)
 	{
 	  q = p->next;
 	  grub_free (p);

Zhang Huan
Tel: (86)10-6260-0549
Mailing: P. O. Box 2704# Beijing
Postcode: 100080
National Research Centre for High Performance Computers Institute of Computing Technology, Chinese Academy of Sciences No. 6, South Kexueyuan Road, Haidian District Beijing, China

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)