Skip to contentSkip to conversation

Small Bug in grub-core/partmap/amiga.c

PATCH [email protected] 2 participants 3 messages Dec 30, 2010 – Dec 31, 2010

lore
Share & tools
lore
#0 lore raw

Alas, AmigaOS has mostly passed beyond the veil, but one can still find small bugs sometimes:

=== modified file 'grub-core/partmap/amiga.c'

partmap/amiga.c +1 -1
@@ -87,7 +87,7 @@
       if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk))
 	return grub_errno;
 
-      if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
+      if (grub_strncmp ((char *) rdsk.magic, "RDSK", sizeof(rdsk.magic)) == 0)
 	{
 	  /* Found the first PART block.  */
 	  next = grub_be_to_cpu32 (rdsk.partitionlst);

I both like and dislike using strcmp() for this purpose. I kind of like
keeping it as a string, but strcmp()... Anyway, minimal solution.

Signature · 4 lines
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         [email protected] PGP F6B23DE0         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
2477\___\_|_/DC21 03A0 5D61 985B <-PGP-> F2BE 6526 ABD2 F6B2\_|_/___/3DE0
#1 lore raw
Quoted 17 lines · On 12/30/2010 07:29 AM, [email protected] wrote:

Alas, AmigaOS has mostly passed beyond the veil, but one can still find small bugs sometimes:

=== modified file 'grub-core/partmap/amiga.c'

partmap/amiga.c +1 -1
@@ -87,7 +87,7 @@
       if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk))
 	return grub_errno;
 
-      if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
+      if (grub_strncmp ((char *) rdsk.magic, "RDSK", sizeof(rdsk.magic)) == 0)
 	{
 	  /* Found the first PART block.  */
 	  next = grub_be_to_cpu32 (rdsk.partitionlst);
Quoted 4 lines

I both like and dislike using strcmp() for this purpose. I kind of like
keeping it as a string, but strcmp()... Anyway, minimal solution.

Nice catch. I fixed it by using the correct grub_memcmp.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#2 lore raw
In reply to [email protected]
Quoted 3 lines · On 12/30/2010 07:29 AM, [email protected] wrote:

Alas, AmigaOS has mostly passed beyond the veil, but one can still find small bugs sometimes:

BTW, Amiga partmap and filesystems support in GRUB is for AROS, not Amiga.

Quoted 19 lines

=== modified file 'grub-core/partmap/amiga.c'

partmap/amiga.c +1 -1
@@ -87,7 +87,7 @@
       if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk))
 	return grub_errno;
 
-      if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
+      if (grub_strncmp ((char *) rdsk.magic, "RDSK", sizeof(rdsk.magic)) == 0)
 	{
 	  /* Found the first PART block.  */
 	  next = grub_be_to_cpu32 (rdsk.partitionlst);

I both like and dislike using strcmp() for this purpose. I kind of like
keeping it as a string, but strcmp()... Anyway, minimal solution.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko