2007-05-17 Jeroen Dekkers <jeroen@dekkers.cx>

* util/biosdisk.c (linux_find_partition): Allocate real_dev on the
	stack instead of on the heap.

	* kern/disk.c (grub_disk_read): Make sure tmp_buf is big enough
	before doing a read on it.

	* configure.ac: Only use -fno-stack-protector for the target
	environment.
This commit is contained in:
jeroen 2007-05-17 19:03:42 +00:00
parent 21c8cbb1ab
commit 1ecb6cf2b4
5 changed files with 20 additions and 66 deletions

View file

@ -1,3 +1,14 @@
2007-05-17 Jeroen Dekkers <jeroen@dekkers.cx>
* util/biosdisk.c (linux_find_partition): Allocate real_dev on the
stack instead of on the heap.
* kern/disk.c (grub_disk_read): Make sure tmp_buf is big enough
before doing a read on it.
* configure.ac: Only use -fno-stack-protector for the target
environment.
2007-05-17 Jeroen Dekkers <jeroen@dekkers.cx> 2007-05-17 Jeroen Dekkers <jeroen@dekkers.cx>
* video/i386/pc/vbe.c (grub_video_vbe_create_render_target): Add * video/i386/pc/vbe.c (grub_video_vbe_create_render_target): Add

34
configure vendored
View file

@ -5784,40 +5784,6 @@ fi
done done
#
# Compiler features.
#
# Smashing stack protector.
# Smashing stack protector.
ssp_possible=yes
{ echo "$as_me:$LINENO: checking whether \`$CC' accepts \`-fstack-protector'" >&5
echo $ECHO_N "checking whether \`$CC' accepts \`-fstack-protector'... $ECHO_C" >&6; }
# Is this a reliable test case?
cat >conftest.$ac_ext <<_ACEOF
void foo (void) { volatile char a[8]; a[3]; }
_ACEOF
# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
# `ac_compile' like this correct, after all?
if eval "$ac_compile -S -fstack-protector -o conftest.s" 2> /dev/null; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
rm -f conftest.s
else
ssp_possible=no
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
# Need that, because some distributions ship compilers that include
# `-fstack-protector' in the default specs.
if [ x"$ssp_possible" = xyes ]; then
CFLAGS=$CFLAGS\ -fno-stack-protector
fi
# #
# Check for target programs. # Check for target programs.
# #

View file

@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
# Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc. # Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
# #
# This configure.ac is free software; the author # This configure.ac is free software; the author
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -151,19 +151,6 @@ fi
# Check for functions. # Check for functions.
AC_CHECK_FUNCS(posix_memalign memalign) AC_CHECK_FUNCS(posix_memalign memalign)
#
# Compiler features.
#
# Smashing stack protector.
grub_CHECK_STACK_PROTECTOR
[# Need that, because some distributions ship compilers that include
# `-fstack-protector' in the default specs.
if [ x"$ssp_possible" = xyes ]; then
CFLAGS=$CFLAGS\ -fno-stack-protector
fi]
# #
# Check for target programs. # Check for target programs.
# #

View file

@ -1,6 +1,6 @@
/* /*
* GRUB -- GRand Unified Bootloader * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,2004,2006 Free Software Foundation, Inc. * Copyright (C) 2002,2003,2004,2006,2007 Free Software Foundation, Inc.
* *
* GRUB is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -414,6 +414,8 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
num = ((size + GRUB_DISK_SECTOR_SIZE - 1) num = ((size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS); >> GRUB_DISK_SECTOR_BITS);
tmp_buf = grub_realloc (tmp_buf, num << GRUB_DISK_SECTOR_BITS);
if ((disk->dev->read) (disk, sector, num, tmp_buf)) if ((disk->dev->read) (disk, sector, num, tmp_buf))
{ {
grub_error_push (); grub_error_push ();

View file

@ -214,9 +214,9 @@ linux_find_partition (char *dev, unsigned long sector)
const char *format; const char *format;
char *p; char *p;
int i; int i;
char *real_dev; char real_dev[PATH_MAX];
real_dev = xstrdup (dev); strcpy(real_dev, dev);
if (have_devfs () && strcmp (real_dev + len - 5, "/disc") == 0) if (have_devfs () && strcmp (real_dev + len - 5, "/disc") == 0)
{ {
@ -234,10 +234,7 @@ linux_find_partition (char *dev, unsigned long sector)
{ {
p = strchr (real_dev + 9, 'd'); p = strchr (real_dev + 9, 'd');
if (! p) if (! p)
{ return 0;
free (real_dev);
return 0;
}
p++; p++;
while (*p && isdigit (*p)) while (*p && isdigit (*p))
@ -246,10 +243,7 @@ linux_find_partition (char *dev, unsigned long sector)
format = "p%d"; format = "p%d";
} }
else else
{ return 0;
free (real_dev);
return 0;
}
for (i = 1; i < 10000; i++) for (i = 1; i < 10000; i++)
{ {
@ -259,15 +253,11 @@ linux_find_partition (char *dev, unsigned long sector)
sprintf (p, format, i); sprintf (p, format, i);
fd = open (real_dev, O_RDONLY); fd = open (real_dev, O_RDONLY);
if (! fd) if (! fd)
{ return 0;
free (real_dev);
return 0;
}
if (ioctl (fd, HDIO_GETGEO, &hdg)) if (ioctl (fd, HDIO_GETGEO, &hdg))
{ {
close (fd); close (fd);
free (real_dev);
return 0; return 0;
} }
@ -276,12 +266,10 @@ linux_find_partition (char *dev, unsigned long sector)
if (hdg.start == sector) if (hdg.start == sector)
{ {
strcpy (dev, real_dev); strcpy (dev, real_dev);
free (real_dev);
return 1; return 1;
} }
} }
free (real_dev);
return 0; return 0;
} }
#endif /* __linux__ */ #endif /* __linux__ */