Commit graph

3479 commits

Author SHA1 Message Date
Lunar
c9ee9bedef syslinux: Support {vesa,}menu.c32. 2015-03-27 15:15:13 +01:00
Steve McIntyre
1a33de8b56 Recognize EFI platform even in case of mismatch between Linux and EFI.
Some x86 systems might be capable of running a 64-bit Linux kernel but
only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for
grub-install to be able to recognise such systems, to set the default
x86 platform correctly.

To allow grub-install to know the size of the firmware rather than
just the size of the kernel, there is now an extra EFI sysfs file to
describe the underlying firmware. Read that if possible, otherwise
fall back to the kernel type as before.

Signed-off-by: Steve McIntyre <steve@einval.com>
2015-03-27 14:51:51 +01:00
Michael Zimmermann
ed07b7e128 Add missing initializers to silence suprious warnings. 2015-03-27 14:44:41 +01:00
Leif Lindholm
d47e8ab4b9 dl_helper: Cleanup
Use the new thumb_get_instruction_word/thumb_set_instruction_word
helpers throughout.

Style cleanup (missing spaces).

Move Thumb MOVW/MOVT handlers into Thumb relocation section of file.
2015-03-27 14:37:16 +01:00
Martin Wilck
cf2b4a36c4 efinet: Check for immediate completition.
This both speeds GRUB up and workarounds unexpected EFI behaviour.
2015-03-27 14:27:56 +01:00
Vladimir Serbinenko
c14f8a9366 modinfo.sh.in: Add missing config variables. 2015-03-27 12:18:25 +01:00
Vladimir Serbinenko
94222b72b5 Makefile.core.def: Remove obsolete LDADD_KERNEL 2015-03-27 12:18:25 +01:00
Vladimir Serbinenko
63034d3261 arp, icmp: Fix handling in case of oversized or invalid packets.
This restrict ARP handling to MAC and IP addresses but in practice we need
only this case anyway and other cases are very rar if exist at all. It makes
code much simpler and less error-prone.
2015-03-27 12:18:25 +01:00
Colin Watson
5974d4ba65 hostfs: Drop unnecessary feature test macros
_BSD_SOURCE was added to allow the use of DT_DIR, but that was removed
in e768b77068.  While adding
_DEFAULT_SOURCE as well works around problems with current glibc,
neither is in fact needed nowadays.
2015-03-23 14:32:30 +00:00
Vladimir Serbinenko
fe6695b7d6 emunet: Fix init error checking.
Otherwise emunet doesn't expose any cards.
2015-03-20 12:59:00 +01:00
Vladimir Serbinenko
9c07daaf91 cacheinfo: Add missing license information. 2015-03-20 11:13:58 +01:00
Andrei Borzenkov
527eeeeee6 core: add LVM RAID1 support
Closes 44534.
2015-03-19 21:30:27 +03:00
Vladimir Serbinenko
5fe21c9968 hfsplus: Fix potential access to uninited memory on invalid FS 2015-03-06 22:33:20 +01:00
Andrei Borzenkov
8842991a56 update gnulib/argp-help.c to fix garbage in grub-mknetdir --help output
argp_help attempts to translate empty string, which results in printing
meta information about translation, like in

bor@opensuse:~/build/grub> grub2-mknetdir --help
Использование: grub2-mknetdir [ПАРАМЕТР…]
Project-Id-Version: grub 2.02-pre2
Report-Msgid-Bugs-To: bug-grub@gnu.org
...

Update gnulib/argp-help.c to the current version which fixes this
(commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d).
2015-03-05 20:19:47 +03:00
Vladimir Serbinenko
dc06aa949b syslinux_parse: Fix the case of unknown localboot.
Reported by: Jordan Uggla
2015-03-04 14:19:29 +01:00
Vladimir Serbinenko
27d1a67f8a Fix canonicalize_file_name clash.
canonicalize_file_name clashed with gnulib function. Additionally
it was declared in 2 places: emu/misc.h and util/misc.h. Added
grub_ prefix and removed second declaration.
2015-03-04 01:00:19 +01:00
Vladimir Serbinenko
9d25b0da9a Remove emu libusb support.
It's disabled by default and has been broken for a long time.
As nobody is interested in fixing and maintaining it, remove it.
2015-03-03 20:59:36 +01:00
Vladimir Serbinenko
064360e667 Remove libgcc dependency.
libgcc for boot environment isn't always present and compatible.
libgcc is often absent if endianness or bit-size at boot is different
from running OS.
libgcc may use optimised opcodes that aren't available on boot time.
So instead of relying on libgcc shipped with the compiler, supply
the functions in GRUB directly.
Tests are present to ensure that those replacement functions behave the
way compiler expects them to.
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko
87ec3b7fa9 Don't continue to query block-size if disk doesn't have it.
Stops poluting screen with a lot of "block-size: exception -21".
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko
66b0e6649b emu/cache: Change declaration of __clear_cache to match builtin declaration.
Fixes compile of arm64-emu.
2015-02-26 22:20:59 +01:00
Vladimir Serbinenko
38b7a30269 arm/dl: Fix handling of nonstandard relocation sizes 2015-02-26 22:10:29 +01:00
Vladimir Serbinenko
7ba066419a gzio: Optimize by removing division. 2015-02-26 22:10:09 +01:00
Vladimir Serbinenko
67a6a9512a raid6: Optimize by removing division. 2015-02-26 22:07:22 +01:00
Vladimir Serbinenko
f76c98b79e dmraid_nvidia: Fix division by 0 and missing byte-swap. 2015-02-26 22:06:19 +01:00
Vladimir Serbinenko
94f701a826 crypto: restrict cipher block size to power of 2.
All current ciphers have blocks which are power of 2 and it's
unlikely to change. Other block length would be tricky to handle anyway.
This restriction allows avoiding extra divisions.
2015-02-26 22:04:40 +01:00
Vladimir Serbinenko
7213c1e028 jpeg: Optimise by replacing division with shifts. 2015-02-26 21:27:32 +01:00
Vladimir Serbinenko
18125877ee png: Optimize by avoiding divisions. 2015-02-26 18:27:43 +01:00
Vladimir Serbinenko
80310ad07d Add missing lib/division.c 2015-02-26 18:22:40 +01:00
Vladimir Serbinenko
f51218bc15 fbblit: Optimize by replacing division with additions and shifts. 2015-02-26 18:14:28 +01:00
Vladimir Serbinenko
dd4889f727 bitmap_scale: Optimize by moving division out of the loop. 2015-02-26 18:13:36 +01:00
Vladimir Serbinenko
6a4ecd276e mips: Fix soft-float handling.
Add -msoft-float alongside clang arguments to specify ABI.
Specify ABI in asm files explicitly.
This trigers asm warning due to gcc failing to propagate -msoft-float
but it's tolerable.
2015-02-23 22:33:28 +01:00
Vladimir Serbinenko
7ea452a142 Add missing grub_ prefix in memcpy invocation 2015-02-23 22:29:33 +01:00
Vladimir Serbinenko
f034fab620 Supply signed division to fix ARM compilation.
Previously we supplied only unsigned divisions on platforms that need software
division.
Yet compiler may itself use a signed division. A typical example would be a
difference between 2 pointers which involves division by object size.
2015-02-23 04:12:04 +01:00
Vladimir Serbinenko
e1d4520bfb acpi: Fix unused function warning. 2015-02-22 14:42:43 +01:00
Vladimir Serbinenko
50ebc8f5f3 i386/tsc: Fix unused function warning on xen. 2015-02-22 13:12:44 +01:00
Vladimir Serbinenko
da9f30b455 mips: Switch to more portable .org
Binary is unchanged.
2015-02-21 20:43:57 +01:00
Vladimir Serbinenko
49e5fcb9fb sparc64: Switch to more portable .org.
Binaries are unchanged.
2015-02-21 20:32:03 +01:00
Vladimir Serbinenko
e77dc3d9a0 kernel-8086: Switch to more portable .org. 2015-02-21 20:24:59 +01:00
Vladimir Serbinenko
3c6043245e qemu: Switch to more portable .org
Binary is checked identical.
2015-02-21 20:13:58 +01:00
Vladimir Serbinenko
8afd8f3b64 qemu: Fix GateA20 enabling.
GateA20 code was inactive due to address error.
2015-02-21 20:00:18 +01:00
Vladimir Serbinenko
e62ca2a870 qemu: Fix compilation 2015-02-21 19:55:53 +01:00
Vladimir Serbinenko
44ff462e83 Remove realmode.S from coreboot and qemu.
It's not used there.
2015-02-21 19:53:18 +01:00
Vladimir Serbinenko
6505b241fd Remove obsolete ADDR32 and DATA32 checks. 2015-02-21 17:44:41 +01:00
Vladimir Serbinenko
37353f0ae5 i386: Remove needless ADDR32 prefixes when address is known and fixed.
Shaves off 6 bytes in lzma_decompress.img.
2015-02-21 17:38:56 +01:00
Vladimir Serbinenko
1998d63688 i386-pc/boot: Explicitly mark kernel_address[_high] as local.
Otherwise apple asm might try to make accesses relocatable.
2015-02-21 17:20:10 +01:00
Vladimir Serbinenko
bc29c6d019 Change dot assignmnet to more portable .org.
Binary is unchanged (verified)
2015-02-21 17:19:01 +01:00
Vladimir Serbinenko
f571dc1af8 i386: Move from explicit ADDR32/DATA32 prefixes to instruction suffixes.
Is more portable.
Binary is unchanged (verified).
2015-02-21 17:13:23 +01:00
Vladimir Serbinenko
87a04adb65 zfs/mzap_lookup: Fix argument types 2015-02-21 16:22:01 +01:00
Vladimir Serbinenko
ec65605af4 wildcard: Mark unused argument as such. 2015-02-21 16:19:09 +01:00
Vladimir Serbinenko
967e5aa591 ofdisk: Exclude floppies from scanning.
It causes similar hang as CD on at least the qemu.
2015-02-21 16:16:48 +01:00
Vladimir Serbinenko
e5851b63e0 mips/startup_raw: Use more portable .asciz 2015-02-21 16:09:46 +01:00
Vladimir Serbinenko
aee2502cb5 Provide __aeabi_mem{cpy,set}
Fixes ARM compilation
2015-02-21 16:07:59 +01:00
Vladimir Serbinenko
2426ac36d3 div_test: Don't try to divide by zero 2015-02-21 16:05:45 +01:00
Vladimir Serbinenko
5537a586e0 ext2: Ignore INCOMPAT_MMP.
It's not really incompatible as long as driver never writes to FS.
2015-02-16 21:08:37 +01:00
Vladimir Serbinenko
e20aa39ea4 ext2: Support META_BG.
This fixes bug that system would become unbootable after ext*
online resize if no resize_inode was created at ext* format time.
2015-02-16 20:53:26 +01:00
Vladimir Serbinenko
e29af836d0 Don't remove initrd= parameter.
Based on simplified patch by Lunar.

Reported by: Lunar
2015-02-16 15:56:26 +01:00
Vladimir Serbinenko
b23635fcff syslinux_parse: Always output comments even if no entries are found. 2015-02-16 10:54:20 +01:00
Andrei Borzenkov
8f5ebb1245 diskfilter_make_raid: more memory leaks in failure path 2015-02-15 10:14:07 +03:00
Vladimir Serbinenko
2ae9457e6e disk/lvm: Use zalloc to ensure that segments are initialised to sane value.
Reported by: EmanueL Czirai.
2015-02-14 20:31:00 +01:00
Daniel Kiper
8e5bc2f4d3 multiboot2: Fix information request tag size calculation
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
2015-02-14 19:26:04 +03:00
Andrei Borzenkov
fc535b32b9 diskfilter: fix double free of lv names for mdraid
Avoid micro-optimization in grub_diskfilter_make_raid and make sure
name and fullname are independent strings. This avoids need to special
case it everywhere else.

Also fix memory leak in failure case in grub_diskfilter_make_raid.

Closes: 41582
2015-02-14 19:08:58 +03:00
Andrei Borzenkov
e27fdbd686 diskfilter: fix crash in validate_lv for mdraid arrays
Commit 750f4bacd3 put LV validation before
actual vg assignment. Make grub_diskfilter_make_raid to assign ->vg as
happens in other cases for consistency. Also clean up redundant code and add
explicit NULL lv->vg check in validate_lv.

Also fix segment validation in validate_lv; it became obvious when crash
was fixed.

Closes: 44199
2015-02-14 17:56:01 +03:00
Leif Lindholm
c0f529ea67 arm: implement additional relocations generated by gcc 4.9 at -O3
GCC 4.9 also generates R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS,
as an alternative to ABS32.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2015-02-03 22:50:08 +00:00
Andrei Borzenkov
12abe75aa0 net/pxe: fix error condition
Test return value of grub_netbuff_reserve(), buf itself cannot be
NULL here.

Found by: Coverity scan.
2015-01-30 22:39:11 +03:00
Andrei Borzenkov
b40fde29a4 net/ip: check result of grub_netbuff_push
Found by: Coverity scan.
2015-01-30 22:09:51 +03:00
Andrei Borzenkov
958167b91c test: fix previous commit - we need to return from subexpression
( ... ) was processed recursively, we need to return from it. Revert
this change.
2015-01-30 20:21:56 +03:00
Andrei Borzenkov
d29259b134 test: do not stop after first file test or closing bracket
Closes: 44115
2015-01-30 20:10:43 +03:00
Andrei Borzenkov
9883307a52 script/execute.c: fix memory leak.
Make sure to continue loop over array after failure to free
allocated strings.

Found by: Coverity scan.
2015-01-28 20:35:28 +03:00
Andrei Borzenkov
2efab86d5a syslinux_parse: fix memory leak.
Found by: Coverity scan.
2015-01-28 20:09:25 +03:00
Andrei Borzenkov
fbb4aa1c05 loader/xnu: fix memory leak.
Foound by: Coverity scan.
2015-01-27 22:12:06 +03:00
Andrei Borzenkov
edc94e4b0b fs/hfsplus: fix memory leak.
Found by: Coverity scan.
2015-01-27 21:19:28 +03:00
Andrei Borzenkov
3900726fa8 fs/zfs/zfscrypt.c: fix indentation. 2015-01-27 21:13:10 +03:00
Andrei Borzenkov
fa13e60527 fs/zfs/zfscrypt.c: fix memory leaks.
Found by: Coverity scan.
2015-01-27 21:12:19 +03:00
Andrei Borzenkov
3db4f05a10 commands/parttool: fix memory leak.
Found by: Coverity scan.
2015-01-27 20:55:25 +03:00
Andrei Borzenkov
e871994849 fs/zfs/zfs.c: fix memory leak.
Found by: Coverity scan.
2015-01-27 20:52:27 +03:00
Andrei Borzenkov
637fc62699 linux/ofpath: fix descriptor leak
Found by: Coverity scan
2015-01-27 20:29:00 +03:00
Andrei Borzenkov
7ba137f628 linux/hostdisk: use strncpy instead of strlcpy
strlcpy is not available on Linux as part of standard libraries.
It probably is not worth extra configure checks espicially as we
need to handle missing function anyway.
2015-01-27 20:00:23 +03:00
Vladimir Serbinenko
9ee5ae1fae Document intentional fallthroughs.
Found by: Coverity scan.
2015-01-27 17:17:58 +01:00
Vladimir Serbinenko
8f95eae423 linux/ofpath: Fix error handling.
Found by: Coverity Scan.
2015-01-27 16:49:49 +01:00
Vladimir Serbinenko
c2fc41990a linux/hostdisk: Limit strcpy size to buffer size.
Found by: Coverity scan.
2015-01-27 16:48:53 +01:00
Vladimir Serbinenko
916733ea6a fs/zfscrypt: Add missing explicit cast.
Found by: Coverity scan.
2015-01-27 16:35:37 +01:00
Vladimir Serbinenko
0daf46fdbd fs/zfs: Fix error handling.
Found by: Coverity Scan.
2015-01-27 16:32:21 +01:00
Vladimir Serbinenko
69a52e95d4 fs/{cbfs,cpio}: Remove useless check if mode is NULL.
Callers already ensure that it's not null.

Found by: Coverity Scan.
2015-01-27 16:32:21 +01:00
Vladimir Serbinenko
4192f2e3d1 commands/acpi: Use ALIGN_UP rather than manual expression.
Improves readability and hopefully automatic scanning.

Found by: Coverity Scan.
2015-01-27 16:32:21 +01:00
Andrei Borzenkov
e61f4eba18 linux/getroot: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov
e2a21238da linux/ofpath: fix various memory leaks.
Found by: Coverity scan.
2015-01-26 23:04:00 +03:00
Andrei Borzenkov
6704abade6 linux/getroot: fix descriptor leak.
Found by: Coverity scan.
2015-01-26 23:02:55 +03:00
Vladimir Serbinenko
c4fcfd8744 vbe: Fix incorrect register usage.
Found by: Coverity scan.
2015-01-26 09:53:39 +01:00
Vladimir Serbinenko
8102540939 unix/password: Fix file descriptor leak.
Found by: Coverity scan.
2015-01-26 09:53:03 +01:00
Vladimir Serbinenko
cba5a85a67 linux/getroot: Fix error handling.
Found by: Coverity scan.
2015-01-26 09:51:48 +01:00
Vladimir Serbinenko
5adc6d76d3 linux/blocklist: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:50:58 +01:00
Vladimir Serbinenko
c14dff3ca7 devmapper/getroot: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:50:27 +01:00
Vladimir Serbinenko
6603c22f31 normal/misc: Close device on all pathes.
Found by: Coverity scan.
2015-01-26 09:49:32 +01:00
Vladimir Serbinenko
73b1e83839 normal/main: Fix error handling.
Found by: Coverity scan.
2015-01-26 09:48:46 +01:00
Vladimir Serbinenko
a05a6e6f92 xnu: Add missing error check.
Found by: Coveriy scan.
2015-01-26 09:45:55 +01:00
Vladimir Serbinenko
e12c3bed90 plan9: Add missing grub_device_close.
Found by: Coverity scan.
2015-01-26 09:45:37 +01:00
Vladimir Serbinenko
ef02b4ca93 multiboot: Simplify to avoid confusing assignment.
Found by: Coverity scan.
2015-01-26 09:43:52 +01:00
Vladimir Serbinenko
1e0d718371 bsd: Add missing null-pointer check.
Found by: Coverity scan.
2015-01-26 09:42:42 +01:00
Vladimir Serbinenko
49978c5c4f lib/syslinux_parse: Add missing error check.
Found by: Coverity scan.
2015-01-26 09:42:04 +01:00
Vladimir Serbinenko
ca7c1fd6f3 lib/syslinux_parse: Fix memory leak.
Found by: Coveriy scan.
2015-01-26 09:41:43 +01:00
Vladimir Serbinenko
aa64393144 lib/syslinux_parse: Add missing alloc check.
Found by: Coverity scan.
2015-01-26 09:40:42 +01:00
Vladimir Serbinenko
21f22c7107 i386/pc/mmap: Fix memset size.
Found by: Coverity scan.
2015-01-26 09:38:11 +01:00
Vladimir Serbinenko
af0be976bf gfxmenu/theme_loader: Add missing allos error check.
Found by: Coverity scan.
2015-01-26 09:37:39 +01:00
Vladimir Serbinenko
bd74a925e5 gfxmenu/icon_manager: Fix null pointer dereference.
Found by: Coverity scan.
2015-01-26 09:37:01 +01:00
Vladimir Serbinenko
a4e33a8b18 fs/ufs: Add missing error check.
Found by: Coverity scan.
2015-01-26 09:36:19 +01:00
Vladimir Serbinenko
66baeffc0f fs/sfs: Fix error check and add sanity check.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko
8c1d086689 fs/reiserfs: Fix sector count overflow.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko
157f9a9cca fs/ntfs: Add sizes sanity checks.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko
bc0ecd7104 fs/ntfs: Add missing free.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko
ca793e9c05 fs/minix: Fix sector promotion to 64-bit.
While on it make GRUB_MINIX_ZONE2SECT into function.

Found by: Coverity scan
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko
ac602ce700 grub_iso9660_read: Explicitly check read_node return value.
Not really needed as grub_errno is already checked but is nicer.

Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Andrei Borzenkov
fb66b512fa commands/fileXX: Fix remaining memory leak.
Found by: Coverity Scan.
2015-01-25 16:36:30 +03:00
Vladimir Serbinenko
d0af2156c3 fs/hfs: Add pointer sanity checks.
Found by: Coverity scan.
2015-01-25 13:18:10 +01:00
Vladimir Serbinenko
4387ca78f0 fs/hfs/hfs_open: Check that mount succeeded.
Found by: Coverity scan.
2015-01-25 01:28:17 +01:00
Vladimir Serbinenko
83543f937a fs/fat: Fix codepath to properly free on error.
Found by: Coverity scan.
2015-01-25 01:27:44 +01:00
Vladimir Serbinenko
faad548ce3 fs/cpio_common: Add a sanity check on namesize.
Found by: Coverity scan.
2015-01-25 00:11:59 +01:00
Vladimir Serbinenko
b6f21bcb98 fs/cbfs: Add missing free.
Found by: Coverity scan.
2015-01-25 00:00:49 +01:00
Vladimir Serbinenko
dd430afbf8 font: Add missing free.
Found by: Coverity Scan.
2015-01-24 21:55:18 +01:00
Vladimir Serbinenko
d1130afa5f biosdisk: Add missing cast.
Found by: Coverity scan.
2015-01-24 21:50:30 +01:00
Vladimir Serbinenko
7656b72b17 disk/geli: Add missing free.
Found by: Coverity scan.
2015-01-24 21:47:51 +01:00
Vladimir Serbinenko
6f43e350ed disk/geli: Add missing seek success check.
Found by: Coverity scan.
2015-01-24 21:46:23 +01:00
Vladimir Serbinenko
f2baeb194b disk/diskfilter: Add missing lv presence check.
Found by: Coverity scan.
2015-01-24 21:44:27 +01:00
Vladimir Serbinenko
4c7337bfe9 disk/cryptodisk: Add missing error check.
Found by: Coverity scan.
2015-01-24 21:38:22 +01:00
Vladimir Serbinenko
2a8200bba8 disk/ahci: Fix device_map_range argument.
Argument is not used on x86, hence it's gone unnoticed.

Found by: Coverity scan.
2015-01-24 21:37:28 +01:00
Vladimir Serbinenko
7d97335942 disk/AFsplitter: check argument validity before doing any allocs.
This avoids possible memory leaks.

Found by: Coverity scan.
2015-01-24 21:33:30 +01:00
Vladimir Serbinenko
3b1b39c082 commands/wildcard: Add missing free.
Found by: Coverity scan.
2015-01-24 21:29:19 +01:00
Vladimir Serbinenko
37ba761b1c commands/verify: Fix sha1 context zeroing-out.
Current code doesn't zero-out context completely. It's a minor issue
really as sha1 init already takes care of initing the context.
2015-01-24 21:27:10 +01:00
Vladimir Serbinenko
6079e67926 commands/tr: Simplify and fix missing parameter test.
Found by: Coverity scan
2015-01-24 21:25:42 +01:00
Vladimir Serbinenko
fbae51dcea commands/syslinux: Add missing free.
Found by: Coverity scan.
2015-01-24 21:23:25 +01:00
Vladimir Serbinenko
4947f11b09 commands/parttool: Add missing device close.
Found by: Coverity scan.
2015-01-24 21:22:02 +01:00
Vladimir Serbinenko
bd50aa323d commands/nativedisk: Add missing device_close.
Found by: Coverity scan.
2015-01-24 21:18:36 +01:00
Vladimir Serbinenko
72bbd8046a commands/macbless: Handle device opening errors correctly.
Wrong variable was checked for errors.

Found by: Coverity scan.
2015-01-24 21:15:14 +01:00
Vladimir Serbinenko
e3b3e53f72 commands/macbless: Fix potential overflow.
Is a minor concern as no such FS would be created under normal circumstances
and failure was benign.

Found by: Coverity scan.
2015-01-24 21:12:02 +01:00
Vladimir Serbinenko
09e84f188b commands/macbless: Remove incorrect grub_free.
Found by: Coverity Scan
2015-01-24 21:08:50 +01:00
Vladimir Serbinenko
f579f097bb commands/legacycfg: Fix resource leaks. 2015-01-24 21:06:23 +01:00
Vladimir Serbinenko
12a9c52e51 zfs: Fix disk-matching logic.
Reported by: Tim Chase <dweeezil>
2015-01-24 20:57:26 +01:00
Vladimir Serbinenko
68cf24376c commands/hdparm: Add missing grub_disk_close.
Found by: Coverity scan.
2015-01-24 20:55:06 +01:00
Vladimir Serbinenko
9d999852a2 gptsync: Add missing device_close.
Found by: Coverity scan
2015-01-24 20:52:02 +01:00
Vladimir Serbinenko
95a8c9182b commands/fileXX: Fix memory leak.
Found by: Coverity Scan.
2015-01-24 20:50:35 +01:00
Vladimir Serbinenko
b04c6d32ce commands/file: Change the confusing loop stop condition.
Old condition was used to zero-out header variable on exit of the loop.
This is correct but confusing. Replace with in-loop logic.

Found by: Coverity Scan.
2015-01-24 20:47:41 +01:00
Vladimir Serbinenko
e902163e48 commands/acpi: Use ALIGN_UP rather than manual expression.
Improves readability and hopefully automatic scanning.

Found by: Coverity Scan.
2015-01-24 20:41:43 +01:00
Vladimir Serbinenko
9ff9d5a54e uhci: Fix null pointer dereference.
Found by: Coverity scan.
2015-01-24 20:38:12 +01:00
Vladimir Serbinenko
7d027b4d3e efidisk: Return the determined root disk even if partition is unknown. 2015-01-24 19:53:13 +01:00
Andrey Borzenkov
2f73d2733c accept also hdX as alias to native Xen disk name
To be compatible with legacy pv-grub, sort disks by increasing order of handle
value. This allows reusing legacy pv-grub menu.lst which is using hdX names.

Suggested-By: Michael Chang <mchang@suse.com>
Closes: 44026
2015-01-23 19:52:45 +03:00
Felix Janda
3bac4caa2b Remove direct _llseek code and require long filesystem libc. 2015-01-22 19:54:36 +01:00
Vladimir Serbinenko
6866f2ba37 Remove potential division by 0 in gfxmenu. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
44b38e4988 grub_menu_init_page: Avoid returning 0 geometry to avoid divisions by 0. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
68581b009f unix/cputime.c: Cache sc_clk_tck and check it for sanity. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
69aee43fa6 * grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a
descriptor_size==0 to avoid potential divisions by zero.
2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
ac8bac2496 haiku/getroot.c (grub_util_find_partition_start_os): Avoid division by zero. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko
4e0a25a4c0 rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid division by zero. 2015-01-21 17:42:14 +01:00
Vladimir Serbinenko
b666e01b9c * grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0. 2015-01-21 17:42:14 +01:00
Vladimir Serbinenko
2e62352bc2 * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that
no division by 0 occurs.
2015-01-21 17:42:14 +01:00
Vladimir Serbinenko
c453760c71 * grub-core/term/gfxterm.c: Avoid division by zero. 2015-01-21 17:42:13 +01:00
Vladimir Serbinenko
e95685dab1 Avoid division by zero in serial. 2015-01-21 17:42:13 +01:00
Vladimir Serbinenko
4816dcac19 * grub-core/video/readers/jpeg.c: Avoid division by zero. 2015-01-21 17:42:13 +01:00
Vladimir Serbinenko
750f4bacd3 * grub-core/disk/diskfilter.c: Validate volumes to avoid division by zero. 2015-01-21 17:42:13 +01:00
Vladimir Serbinenko
475bffeae6 * grub-core/fs/zfs.c: Avoid divisions by zero. 2015-01-21 17:42:12 +01:00
Vladimir Serbinenko
9deb46e363 * grub-core/fs/btrfs.c: Avoid divisions by zero. 2015-01-21 17:42:12 +01:00
Vladimir Serbinenko
065ed900d4 grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0. 2015-01-21 17:42:12 +01:00
Vladimir Serbinenko
111ab3b9cc osdep/linux/blocklist.c (grub_install_get_blocklist): Check blocksize validity. 2015-01-21 17:42:12 +01:00
Vladimir Serbinenko
4200ad44fe * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity. 2015-01-21 17:42:12 +01:00
Vladimir Serbinenko
f1959b1695 * grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size
validity.
2015-01-21 17:42:11 +01:00
Vladimir Serbinenko
935863518f grub_dmraid_nv_detect: Do not divide by zero. 2015-01-21 17:42:11 +01:00
Vladimir Serbinenko
98f74998d5 * grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem sanity checks. 2015-01-21 17:42:11 +01:00
Vladimir Serbinenko
5ed3a5d049 * grub-core/fs/minix.c: Additional filesystem sanity checks. 2015-01-21 17:42:11 +01:00
Vladimir Serbinenko
47cd2645dd * grub-core/fs/ext2.c (grub_ext2_mount): Additional checks for superblock validity. 2015-01-21 17:42:11 +01:00
Vladimir Serbinenko
245e21b2b5 grub_ufs_mount: Check that sblock.ino_per_group is not 0. 2015-01-21 17:42:11 +01:00
Vladimir Serbinenko
9201cd79a3 Reject NILFS2 superblocks with over 1GiB blocks.
* grub-core/fs/nilfs2.c (grub_nilfs2_valid_sb): Check that
	block size is <= 1GiB.
2015-01-21 17:42:10 +01:00
Vladimir Serbinenko
f27ccb584c grub_ata_setaddress: Check that geometry is sane when using CHS addressing. 2015-01-21 17:42:10 +01:00
Vladimir Serbinenko
1dfe3f973e * grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0. 2015-01-21 17:42:10 +01:00
Vladimir Serbinenko
44461d5af2 grub_cmd_play: Avoid division by zero. 2015-01-21 17:42:10 +01:00
Vladimir Serbinenko
30e177a05b grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past the end of file. 2015-01-21 17:42:06 +01:00
Vladimir Serbinenko
af435524cd grub_fshelp_read_file: Don't attempt to read past the end of file. 2015-01-21 17:38:04 +01:00
Vladimir Serbinenko
66ce4d1aef grub_script_lexer_yywrap: Update len synchronously with line. 2015-01-21 17:38:01 +01:00
Vladimir Serbinenko
59d4036594 Replace explicit sizeof divisions by ARRAY_SIZE. 2015-01-21 17:37:31 +01:00
Kris Moore
ba3031f996 Support GELI v6 and v7 2015-01-19 21:56:41 +03:00
Andrei Borzenkov
bac5d1a64a Fix serial --rtscts option processing 2014-12-09 21:56:39 +03:00
David Kozub
17328db3b3 grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable
The unaligned local in __aeabi_uidivmod leads to a store to a 64bit
value at an address that is not divisible by 8 (in grub_divmod64).
The compiler most likely generates a STRD instruction to store it and
this causes an exception.

Fixes Savannah bug #43632.

This includes improvements done by Leif Lindholm.
2014-12-07 20:16:29 +03:00
Peter Nelson
58f66137a3 * grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse chunks. 2014-12-07 17:57:49 +01:00
Curtis Larsen
06eadf5ebf fix double free in grub_net_recv_tcp_packet
Using the http module to download config files, produces memory errors,
after the config file is downloaded.

The error was traced to the tcp stack in grub-core/net/tcp.c. The wrong
netbuff pointer was being freed in the clean up loop.

Changing the code to free the correct netbuff pointer removes the runtime
error.

Closes 42765.
2014-12-07 11:28:57 +03:00
Andrei Borzenkov
ebb3d958aa fix memory corruption in pubkey filter over network
grub_pubkey_open closed original file after it was read; it set
io->device to NULL to prevent grub_file_close from trying to close device.
But network device itself is stacked (net -> bufio); and bufio preserved
original netfs file which hold reference to device. grub_file_close(io)
called grub_bufio_close which called grub_file_close for original file.
grub_file_close(netfs-file) now also called grub_device_close which
freed file->device->net. So file structure returned by grub_pubkey_open
now had device->net pointed to freed memory. When later file was closed,
it was attempted to be freed again.

Change grub_pubkey_open to behave like other filters - preserve original
parent file and pass grub_file_close down to parent. In this way only the
original file will close device. We really need to move this logic into
core instead.

Also plug memory leaks in error paths on the way.

Reported-By: Robert Kliewer <robert.kliewer@gmail.com>
Closes: bug #43601
2014-12-05 21:17:08 +03:00
Andrei Borzenkov
3173c7501c grub-core/loader/i386/xen_fileXX.c: memory leak in grub_xen_get_infoXX
CID: 73645, 73782
2014-12-01 21:23:54 +03:00
Andrei Borzenkov
03d79a878b grub-core/fs/zfs/zfsinfo.c: memory leak in print_vdev_info
CID: 73635
2014-12-01 20:54:12 +03:00
Andrei Borzenkov
dbbac5a04c grub-core/lib/syslinux_parse.c: do not free array
say->msg is inline array in a structure and should not be freed.
CID: 73610
2014-11-30 18:49:14 +03:00
Andrei Borzenkov
343dad410e grub-core/disk/lzopio.c: fix double free in error path
CID: 73665
2014-11-28 22:37:00 +03:00
Andrei Borzenkov
bbbcb791ed grub-core/disk/geli.c: fix memory leaks in error paths
CID: 73813, 73710
2014-11-28 22:23:30 +03:00
Andrei Borzenkov
ea44693fc8 grub-core/disk/luks.c: fix use after free and memory leaks
configure_ciphers:

- several memory leaks where allocated ciphers were not freed. CID: 73813,
73710

- use after free. It is probably quite innocent as grub is single threaded,
but could potentially be a problem with memory allocator debugger turned on.
CID: 73730

luks_recover_key:

- memory leak. CID: 73854
2014-11-28 21:12:00 +03:00
Michael Chang
7c4b6b7bb4 send router solicitation for ipv6 address autoconf v2
Many routers have long router advertisment interval configured by
default. The Neighbor Discovery protocol (RFC4861) has defined default
MaxRtrAdvInterval value as 600 seconds and
MinRtrAdvInterval as 0.33*MaxRtrAdvInterval. This makes
net_ipv6_autoconf fails more often than not as currently it passively
listens the RA message to perfom address autoconfiguration.

This patch tries to send router solicitation to overcome the problem of
long RA interval.

v2:
use cpu_to_be macro for network byte order conversion
add missing error handling
2014-11-28 20:21:34 +03:00
Leif Lindholm
004a2b1efd efi: check *path non-null before grub_strrchr
The EFI version of grub_machine_get_bootlocation crops the boot image
name back to the last / in order to get a directory path. However, it
does not check that *name is actually set before calling grub_strrchr
to do this, and neither does grub_strrchr before dereferencing a NULL
pointer.

Parent function, grub_set_prefix_and_root, does check the pointer
before using.
2014-11-17 14:11:01 +00:00
Michael Chang
72ec399ad8 icmp6 fix no respond to neighbor solicit message
The structure size used in grub_netbuff_pull to get the pointer to
option header is apparently wrong, which leads to subsequent range check
failed and therefore not responding to any neighbor solicit message in my
testing.
2014-11-03 20:03:04 +03:00
Andrei Borzenkov
9a67e1ac8e Use full initializer for initrd_ctx to avoid fatal warnings with older GCC
struct ... foo = { 0, } is valid initializer, but older GCC emits
warning which is fatal error due to -Werror=missing-field-initializer.
So simply use full initializer to avoid these errors. This was fixed
probably in GCC 4.7.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
2014-10-14 20:12:15 +04:00
Andrey Borzenkov
954fe77163 cleanup: grub_cpu_to_XXX_compile_time for constants
This tries to catch all cases where grub_cpu_to_XXX was used for constant
expressions (including sizeof).
2014-09-22 20:47:10 +04:00
Valentin Dornauer
0f1f95c7b7 ACPIhalt: Add more ACPI opcodes.
The AML parser implements only a small subset of possible AML
	opcodes. On the Fujitsu Lifebook E744 this and another bug in
	the parser (incorrect handling of TermArg data types) would lead
	to the laptop not turning off (_S5 not found).

	* grub-core/commands/acpihalt.c: Support OpAlias in the AML parser;
	in skip_ext_op(), handle some Type2Opcodes more correctly (TermArgs
	aren't always simply strings!); Add function to skip TermArgs
	* include/grub/acpi.h: Add new opcodes
2014-09-21 18:58:14 +02:00
Vladimir Serbinenko
41c6f91fce * grub-core/normal/main.c: Don't drop to rescue console in
case of password-protected prompt and no menu entries.
2014-09-21 18:51:09 +02:00
Vladimir Serbinenko
7c378c3964 * grub-core/commands/keylayouts.c: Ignore unknown keys. 2014-09-21 18:49:49 +02:00
Vladimir Serbinenko
2988a849fc * grub-core/gmodule.pl.in: Accept newer binutils which output
empty column rather than 0x0.
2014-09-21 18:23:23 +02:00
Vladimir Serbinenko
5e42618e00 Fix wrong commit 2014-09-21 18:18:03 +02:00
Michael Chang
0aece00c54 * grub-core/osdep/unix/config.c: Remove extraneous comma. 2014-09-21 17:49:13 +02:00
Peter Jones
631a820038 Initialized initrd_ctx so we don't free a random pointer from the stack.
Currently, if "linux" fails, the "goto fail;" in grub_cmd_initrd sends us
into grub_initrd_close() without grub_initrd_init() being called, and thus
it never clears initrd_ctx->components.  grub_initrd_close() then frees that
address, which is stale data from the stack.  If the stack happens to have a
stale *address* there that matches a recent allocation, then you'll get a
double free later.

So initialize the memory up front.

Signed-off-by: Peter Jones <pjones@redhat.com>
2014-09-21 10:36:42 +04:00