Commit Graph

87 Commits

Author SHA1 Message Date
Glenn Washburn ac301e4dd0 script: Do not allow a delimiter between function name and block start
Currently the following is valid syntax but should be a syntax error:

  grub> function f; { echo HERE; }
  grub> f
  HERE

This fix is not backward compatible, but current syntax is not documented
either and has no functional value. So any scripts with this unintended
syntax are technically syntactically incorrect and should not be relying
on this behavior.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-18 22:31:30 +02:00
Glenn Washburn c98a78ae81 lexer: char const * should be const char *
Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-18 22:31:30 +02:00
Chris Coulson 426f57383d script: Avoid a use-after-free when redefining a function during execution
Defining a new function with the same name as a previously defined
function causes the grub_script and associated resources for the
previous function to be freed. If the previous function is currently
executing when a function with the same name is defined, this results
in use-after-frees when processing subsequent commands in the original
function.

Instead, reject a new function definition if it has the same name as
a previously defined function, and that function is currently being
executed. Although a behavioural change, this should be backwards
compatible with existing configurations because they can't be
dependent on the current behaviour without being broken.

Fixes: CVE-2020-15706

Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:48 +02:00
Peter Jones 3f05d693d1 malloc: Use overflow checking primitives where we do complex allocations
This attempts to fix the places where we do the following where
arithmetic_expr may include unvalidated data:

  X = grub_malloc(arithmetic_expr);

It accomplishes this by doing the arithmetic ahead of time using grub_add(),
grub_sub(), grub_mul() and testing for overflow before proceeding.

Among other issues, this fixes:
  - allocation of integer overflow in grub_video_bitmap_create()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_png_decode_image_header()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_squash_read_symlink()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_ext2_read_symlink()
    reported by Chris Coulson,
  - allocation of integer overflow in read_section_as_string()
    reported by Chris Coulson.

Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:47 +02:00
Peter Jones f725fa7cb2 calloc: Use calloc() at most places
This modifies most of the places we do some form of:

  X = malloc(Y * Z);

to use calloc(Y, Z) instead.

Among other issues, this fixes:
  - allocation of integer overflow in grub_png_decode_image_header()
    reported by Chris Coulson,
  - allocation of integer overflow in luks_recover_key()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_lvm_detect()
    reported by Chris Coulson.

Fixes: CVE-2020-14308

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:47 +02:00
Peter Jones a4d3fbdff1 yylex: Make lexer fatal errors actually be fatal
When presented with a command that can't be tokenized to anything
smaller than YYLMAX characters, the parser calls YY_FATAL_ERROR(errmsg),
expecting that will stop further processing, as such:

  #define YY_DO_BEFORE_ACTION \
        yyg->yytext_ptr = yy_bp; \
        yyleng = (int) (yy_cp - yy_bp); \
        yyg->yy_hold_char = *yy_cp; \
        *yy_cp = '\0'; \
        if ( yyleng >= YYLMAX ) \
                YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
        yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1 , yyscanner); \
        yyg->yy_c_buf_p = yy_cp;

The code flex generates expects that YY_FATAL_ERROR() will either return
for it or do some form of longjmp(), or handle the error in some way at
least, and so the strncpy() call isn't in an "else" clause, and thus if
YY_FATAL_ERROR() is *not* actually fatal, it does the call with the
questionable limit, and predictable results ensue.

Unfortunately, our implementation of YY_FATAL_ERROR() is:

   #define YY_FATAL_ERROR(msg)                     \
     do {                                          \
       grub_printf (_("fatal error: %s\n"), _(msg));     \
     } while (0)

The same pattern exists in yyless(), and similar problems exist in users
of YY_INPUT(), several places in the main parsing loop,
yy_get_next_buffer(), yy_load_buffer_state(), yyensure_buffer_stack,
yy_scan_buffer(), etc.

All of these callers expect YY_FATAL_ERROR() to actually be fatal, and
the things they do if it returns after calling it are wildly unsafe.

Fixes: CVE-2020-10713

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:47 +02:00
Peter Jones d5a32255de misc: Make grub_strtol() "end" pointers have safer const qualifiers
Currently the string functions grub_strtol(), grub_strtoul(), and
grub_strtoull() don't declare the "end" pointer in such a way as to
require the pointer itself or the character array to be immutable to the
implementation, nor does the C standard do so in its similar functions,
though it does require us not to change any of it.

The typical declarations of these functions follow this pattern:

long
strtol(const char * restrict nptr, char ** restrict endptr, int base);

Much of the reason for this is historic, and a discussion of that
follows below, after the explanation of this change.  (GRUB currently
does not include the "restrict" qualifiers, and we name the arguments a
bit differently.)

The implementation is semantically required to treat the character array
as immutable, but such accidental modifications aren't stopped by the
compiler, and the semantics for both the callers and the implementation
of these functions are sometimes also helped by adding that requirement.

This patch changes these declarations to follow this pattern instead:

long
strtol(const char * restrict nptr,
       const char ** const restrict endptr,
       int base);

This means that if any modification to these functions accidentally
introduces either an errant modification to the underlying character
array, or an accidental assignment to endptr rather than *endptr, the
compiler should generate an error.  (The two uses of "restrict" in this
case basically mean strtol() isn't allowed to modify the character array
by going through *endptr, and endptr isn't allowed to point inside the
array.)

It also means the typical use case changes to:

  char *s = ...;
  const char *end;
  long l;

  l = strtol(s, &end, 10);

Or even:

  const char *p = str;
  while (p && *p) {
	  long l = strtol(p, &p, 10);
	  ...
  }

This fixes 26 places where we discard our attempts at treating the data
safely by doing:

  const char *p = str;
  long l;

  l = strtol(p, (char **)&ptr, 10);

It also adds 5 places where we do:

  char *p = str;
  while (p && *p) {
	  long l = strtol(p, (const char ** const)&p, 10);
	  ...
	  /* more calls that need p not to be pointer-to-const */
  }

While moderately distasteful, this is a better problem to have.

With one minor exception, I have tested that all of this compiles
without relevant warnings or errors, and that /much/ of it behaves
correctly, with gcc 9 using 'gcc -W -Wall -Wextra'.  The one exception
is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
how to build.

Because the C standard defined type-qualifiers in a way that can be
confusing, in the past there's been a slow but fairly regular stream of
churn within our patches, which add and remove the const qualifier in many
of the users of these functions.  This change should help avoid that in
the future, and in order to help ensure this, I've added an explanation
in misc.h so that when someone does get a compiler warning about a type
error, they have the fix at hand.

The reason we don't have "const" in these calls in the standard is
purely anachronistic: C78 (de facto) did not have type qualifiers in the
syntax, and the "const" type qualifier was added for C89 (I think; it
may have been later).  strtol() appears to date from 4.3BSD in 1986,
which means it could not be added to those functions in the standard
without breaking compatibility, which is usually avoided.

The syntax chosen for type qualifiers is what has led to the churn
regarding usage of const, and is especially confusing on string
functions due to the lack of a string type.  Quoting from C99, the
syntax is:

 declarator:
  pointer[opt] direct-declarator
 direct-declarator:
  identifier
  ( declarator )
  direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
  ...
  direct-declarator [ type-qualifier-list[opt] * ]
  ...
 pointer:
  * type-qualifier-list[opt]
  * type-qualifier-list[opt] pointer
 type-qualifier-list:
  type-qualifier
  type-qualifier-list type-qualifier
 ...
 type-qualifier:
  const
  restrict
  volatile

So the examples go like:

const char foo;			// immutable object
const char *foo;		// mutable pointer to object
char * const foo;		// immutable pointer to mutable object
const char * const foo;		// immutable pointer to immutable object
const char const * const foo; 	// XXX extra const keyword in the middle
const char * const * const foo; // immutable pointer to immutable
				//   pointer to immutable object
const char ** const foo;	// immutable pointer to mutable pointer
				//   to immutable object

Making const left-associative for * and right-associative for everything
else may not have been the best choice ever, but here we are, and the
inevitable result is people using trying to use const (as they should!),
putting it at the wrong place, fighting with the compiler for a bit, and
then either removing it or typecasting something in a bad way.  I won't
go into describing restrict, but its syntax has exactly the same issue
as with const.

Anyway, the last example above actually represents the *behavior* that's
required of strtol()-like functions, so that's our choice for the "end"
pointer.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-28 12:41:29 +01:00
Matthew Garrett d3a5e812c5 verifiers: Verify commands executed by grub
Pass all commands executed by GRUB to the verifiers layer. Most verifiers will
ignore this, but some (such as the TPM verifier) want to be able to measure and
log each command executed in order to ensure that the boot state is as expected.

Signed-off-by: Matthew Garrett <mjg59@google.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-12-12 13:17:52 +01:00
Vladimir Serbinenko c36c2a8640 yylex: Explicilty cast fprintf to void.
It's needed to avoid warning on recent GCC.
2017-08-14 14:11:43 +02:00
Andrei Borzenkov 2fb8cd26a9 script: fix double free in lexer
yylex_destroy() already frees scanner.

Found by: Coverity scan.
CID: 176636
2017-02-12 09:23:34 +03:00
Vladimir Serbinenko 342d6edb97 yylex: use grub_fatal for exit.
lexer calls yylex_fatal on fatal internal errors. yylex_fatal itself is
declared as noreturn and calls exit. Returning from noreturn function has
unpredictable consequences.
2016-02-12 12:34:54 +01:00
Colin Watson 47e67d809c Remove pragmas related to -Wunreachable-code
-Wunreachable-code has been a no-op since GCC 4.5; GRUB hasn't been
compiled with it since 2012; and GCC 6 produces "error:
'-Wunreachable-code' is not an option that controls warnings" for these.

Fixes Debian bug #812047.
2016-01-20 15:56:55 +00:00
Andrei Borzenkov b95e926788 script: fix memory leak
Found by: Coverity scan.
CID: 96637
2016-01-12 22:50:30 +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
Vladimir Serbinenko 66ce4d1aef grub_script_lexer_yywrap: Update len synchronously with line. 2015-01-21 17:38:01 +01:00
Vladimir Serbinenko 080603f0b0 Decrease stack usage in lexer.
We have only 92K of stack and using over 4K per frame is wasteful

	* grub-core/script/yylex.l (yyalloc), (yyfree), (yyrealloc): Declare
	as macros so that compiler would remove useless structure on stack.
	Better solution would be to fix flex not to put this structure on
	the stack but flex is external program.
2013-11-16 16:37:59 +01:00
Vladimir Serbinenko ec0ebb3fc2 Remove vestiges of -Wunsafe-loop-optimisations.
* conf/Makefile.common (CFLAGS_GNULIB): Remove
	-Wno-unsafe-loop-optimisations.
	* grub-core/commands/legacycfg.c: Remove -Wunsafe-loop-optimisations
	pragma.
	* grub-core/io/gzio.c: Likewise.
	* grub-core/script/parser.y: Likewise.
	* grub-core/script/yylex.l: Likewise.
	* util/grub-mkfont.c: Likewise.
2013-11-07 02:25:31 +01:00
Vladimir 'phcoder' Serbinenko 9688cae2eb * grub-core/script/yylex.l: Fix LSQBR2 and RSQBR2. It's not
currently used so this doesn't really have any effect.
	Reported by:  	Douglas Ray <dougray>
2013-10-17 01:28:24 +02:00
Andrey Borzenkov 593e430cd6 * grub-core/script/execute.c (grub_script_execute_sourcecode): Split
off new function grub_script_execute_new_scope. Change callers to use
	either of them as appropriate.
	* grub-core/commands/eval.c: New command eval.
	* docs/grub.texi (Commands): Document it.
2013-06-07 18:36:42 +02:00
Vladimir 'phcoder' Serbinenko bdc4add8ca * grub-core/script/execute.c (grub_script_arglist_to_argv): Fix
handling of variables containing backslash.
2013-04-29 12:02:26 +02:00
Vladimir 'phcoder' Serbinenko 73b5d90fe2 * grub-core/script/execute.c (grub_script_arglist_to_argv): Move
append out of its parent.
2013-03-03 15:26:29 +01:00
Vladimir 'phcoder' Serbinenko 396d4091e7 * grub-core/script/execute.c (gettext_append): Remove nested functions. 2013-03-02 12:17:52 +01:00
Vladimir 'phcoder' Serbinenko 4542e71b8b * grub-core/script/lexer.c (grub_script_lexer_init): Rename getline
argument to prevent name collision.
2013-01-16 09:06:11 +01:00
Colin Watson 09fd6d8293 Remove nested functions from script reading and parsing.
* grub-core/kern/parser.c (grub_parser_split_cmdline): Add
getline_data argument, passed to getline.
* grub-core/kern/rescue_parser.c (grub_rescue_parse_line): Add
getline_data argument, passed to grub_parser_split_cmdline.
* grub-core/script/lexer.c (grub_script_lexer_yywrap): Pass
lexerstate->getline_data to lexerstate->getline.
(grub_script_lexer_init): Add getline_data argument, saved in
lexerstate->getline_data.
* grub-core/script/main.c (grub_normal_parse_line): Add getline_data
argument, passed to grub_script_parse.
* grub-core/script/script.c (grub_script_parse): Add getline_data
argument, passed to grub_script_lexer_init.
* include/grub/parser.h (grub_parser_split_cmdline): Update
prototype.  Update all callers to pass appropriate getline data.
(struct grub_parser.parse_line): Likewise.
(grub_rescue_parse_line): Likewise.
* include/grub/reader.h (grub_reader_getline_t): Add void *
argument.
* include/grub/script_sh.h (struct grub_lexer_param): Add
getline_data member.
(grub_script_parse): Update prototype.  Update all callers to pass
appropriate getline data.
(grub_script_lexer_init): Likewise.
(grub_normal_parse_line): Likewise.

* grub-core/commands/legacycfg.c (legacy_file_getline): Add unused
data argument.
* grub-core/kern/parser.c (grub_parser_execute: getline): Make
static instead of nested.  Rename to ...
(grub_parser_execute_getline): ... this.
* grub-core/kern/rescue_reader.c (grub_rescue_read_line): Add unused
data argument.
* grub-core/normal/main.c (read_config_file: getline): Make static
instead of nested.  Rename to ...
(read_config_file_getline): ... this.
(grub_normal_read_line): Add unused data argument.
* grub-core/script/execute.c (grub_script_execute_sourcecode:
getline): Make static instead of nested.  Rename to ...
(grub_script_execute_sourcecode_getline): ... this.
* util/grub-script-check.c (main: get_config_line): Make static
instead of nested.
2013-01-15 12:03:25 +00:00
Vladimir 'phcoder' Serbinenko 9cc836a27b * grub-core/script/yylex.l: Ignore unused-function and sign-compare
warnings.
2012-09-05 08:51:31 +02:00
Vladimir 'phcoder' Serbinenko cde393c9a3 * grub-core/script/execute.c (grub_script_arglist_to_argv): Escape
blocks.
2012-06-21 22:02:09 +02:00
Vladimir 'phcoder' Serbinenko 485568790c Fix wildcard regexp dot and other special characters handling.
Reported by: Robert Mabee.

	* grub-core/commands/wildcard.c (isregexop): Add "|+{}[]?".
	(make_regex): Escape "|+{}[]". Transform '?' to '.?'.
	(split_path): Trigger expansion on '?'.
	(unescape): New function.
	(wildcard_expand): Unescape parts copied without globbing.
	* grub-core/script/execute.c (wildcard_escape): Escape '?'.
	(grub_script_arglist_to_argv): Don't unescape expansions.
2012-06-19 14:13:19 +02:00
Vladimir 'phcoder' Serbinenko 5e619f408d Fix wildcard escaping.
* grub-core/commands/wildcard.c (wildcard_escape): Moved from here ...
	* grub-core/script/execute.c (wildcard_escape): .. to here.
	Don't escape dot.
	* grub-core/commands/wildcard.c (wildcard_unescape): Moved from here ...
	* grub-core/script/execute.c (wildcard_unescape): .. to here.
	Don't escape dot.
	* grub-core/script/execute.c (gettext_append): Always escape.
	(grub_script_arglist_to_argv): Always handle escaping/unescaping.
	* grub-core/script/yylex.l: Don't cut away the escaping.
	* tests/grub_script_echo1.in: Add tests with wildcard.
2012-06-08 22:54:21 +02:00
Vladimir 'phcoder' Serbinenko eea1e26e52 * grub-core/script/yylex.l: Ugly fix for "\\\n ".
* tests/grub_script_echo1.in: Add tests.
2012-05-08 23:20:02 +02:00
Vladimir 'phcoder' Serbinenko ac6fd21803 * grub-core/script/argv.c (grub_script_argv_split_append): Skip leading
spaces.
	* tests/grub_script_leading_whitespace.in: New file.
	* Makefile.util.def (grub_script_leading_whitespace): New test.
2012-03-19 13:29:43 +01:00
Vladimir 'phcoder' Serbinenko 0ae4f0bddb * grub-core/commands/i386/pc/play.c: Improve TRANSLATORS comments.
* grub-core/commands/regexp.c: Likewise.
	* grub-core/loader/i386/linux.c: Likewise.
	* grub-core/partmap/msdos.c: Likewise.
	* grub-core/script/execute.c: Likewise.
	* grub-core/term/gfxterm.c: Likewise.
2012-03-11 23:36:35 +01:00
Vladimir 'phcoder' Serbinenko 546fbe9b5a Add variable parsing in $"..." and fix several mismatches with bash.
* Makefile.util.def (grub_script_gettext): New test.
	* grub-core/script/execute.c (parse_string): New function.
	(gettext_append): Likewise.
	(grub_script_arglist_to_argv): Use gettext_append.
	* grub-core/script/yylex.l: Fix slash and newline handling in $"...".
	* tests/grub_script_gettext.in: New file.
2012-03-11 14:46:48 +01:00
Vladimir 'phcoder' Serbinenko e8e0566b0c * grub-core/commands/videoinfo.c: Add TRANSLATORS comments.
* grub-core/commands/xnu_uuid.c: Likewise.
	* grub-core/loader/efi/appleloader.c: Likewise.
	* grub-core/script/execute.c: Likewise.
	* grub-core/script/main.c: Likewise.
	* util/grub-mkfont.c: Likewise.
2012-03-10 13:19:46 +01:00
Vladimir 'phcoder' Serbinenko ef292a8775 * grub-core/net/http.c: Add TRANSLATORS comments.
* grub-core/normal/cmdline.c: Likewise.
	* grub-core/normal/misc.c: Likewise.
	* grub-core/partmap/msdos.c: Likewise.
	* grub-core/parttool/msdospart.c: Likewise.
	* grub-core/script/execute.c: Likewise.
	* grub-core/script/main.c: Likewise.
	* grub-core/term/terminfo.c: Likewise.
	* grub-core/video/bitmap.c: Likewise.
	* util/grub-install.in: Likewise.
	* util/grub-mkimage.c: Likewise.
	* util/grub-mklayout.c: Likewise.
	* util/grub-setup.c: Likewise.
2012-03-05 16:42:26 +01:00
Vladimir 'phcoder' Serbinenko 0d31b7df86 * grub-core/script/execute.c (grub_script_return): Replace ambiguous
"scope" with "body".
2012-03-04 12:14:33 +01:00
Vladimir 'phcoder' Serbinenko 7e8fac16ad $"..." support in scripts.
* grub-core/script/execute.c (grub_script_arglist_to_argv): Handle
	GRUB_SCRIPT_ARG_TYPE_GETTEXT.
	* grub-core/script/yylex.l: Likewise.
	* include/grub/script_sh.h (GRUB_SCRIPT_ARG_TYPE_GETTEXT): New enum
	value.
2012-02-26 19:02:46 +01:00
Vladimir 'phcoder' Serbinenko 67093bc0ed Another round of string clarification and adding TRANSLATORS comments. 2012-02-26 17:28:05 +01:00
Vladimir 'phcoder' Serbinenko 4e27343fb0 * conf/Makefile.common (CFLAGS_GNULIB): Add
-Wno-unsafe-loop-optimizations.
	* configure.ac: Remove -Wmissing-declarations and -Wmissing-prototypes
	on tools.
	* grub-core/commands/legacycfg.c: Add pragma to skip
	-Wunsafe-loop-optimizations.
	(check_password_md5_real): Fix loop counter type.
	* grub-core/commands/testload.c (grub_cmd_testload): Fix over the EOF
	reading.
	* grub-core/disk/ldm.c (grub_util_get_ldm): Fix logic error.
	* grub-core/fs/zfs/zfs_sha256.c (zio_checksum_SHA256): Add safety
	loop condition.
	* grub-core/io/gzio.c: Add pragma to skip -Wunsafe-loop-optimizations.
	* grub-core/lib/LzmaEnc.c (GetOptimum): Avoid possible infinite loop.
	* grub-core/net/net.c (grub_net_route_address): Add safety loop
	condition.
	* grub-core/normal/charset.c (bidi_line_wrap): Likewise.
	* grub-core/normal/cmdline.c (grub_set_history): Fix loop types and
	avoid possible infinite loops.
	* grub-core/script/parser.y: Add pragma to skip -Wmissing-declarations
	and -Wunsafe-loop-optimizations.
	* grub-core/script/yylex.l: Likewise.
	* util/grub-mkfont.c: Add pragma to skip -Wunsafe-loop-optimizations.
	(print_glyphs): Avoid infinite loops.
	* util/grub-mkimage.c (compress_kernel_xz): Fix format security.
2012-02-24 12:30:32 +01:00
Vladimir 'phcoder' Serbinenko d9a62292e3 * grub-core/script/execute.c (grub_script_break): Clarify logic.
Better error handling.
	(grub_script_return): Likewise.
	* grub-core/script/lexer.c (grub_script_lexer_yywrap): Likewise.
2012-02-12 21:33:48 +01:00
Vladimir 'phcoder' Serbinenko d61386e21d Improve string. Gettextize. 2012-02-12 15:25:25 +01:00
Vladimir 'phcoder' Serbinenko ebcecdf1c3 Increase warning level.
* conf/Makefile.common (CFLAGS_GNULIB): Add -Wno-redundant-decls
	-Wno-unreachable-code -Wno-conversion -Wno-old-style-definition.
	* configure.ac (HOST_CFLAGS): Add bunch of -W arguments.
	(TARGET_CFLAGS): Likewise.
	(HOST_CFLAGS): Add -Werror unless --disable-werror is activated.
	* grub-core/Makefile.core.def (decompressor_xz): Add
	-Wno-unreachable-code.
	(normal): Add -Wno-redundant-decls.
	(xzio): Add -Wno-unreachable-code.
	(lzopio): Add -Wno-redundant-decls -Wno-error.
	* grub-core/commands/acpi.c: Add exception to -Wcast-align.
	* grub-core/commands/lsacpi.c: Add exception to -Wcast-align.
	* grub-core/gensymlist.sh: Add exception to -Wmissing-format-attribute.
	* grub-core/kern/dl.c: Add exception to -Wcast-align.
	* grub-core/kern/efi/efi.c (grub_efi_modules_addr): Likewise.
	* grub-core/kern/i386/coreboot/init.c: Add exception to
	-Wsuggest-attribute=noreturn.
	* grub-core/kern/ia64/dl.c: Add exception to -Wcast-align.
	* grub-core/kern/ia64/dl_helper.c: Likewise.
	* grub-core/kern/mips/dl.c: Likewise.
	* grub-core/kern/sparc64/dl.c: Likewise.
	* grub-core/lib/LzmaEnc.c: Add exception to -Wshadow.
	* grub-core/lib/libgcrypt_wrap/cipher_wrap.h (memcpy): Likewise.
	(memcmp): Likewise.
	* grub-core/lib/pbkdf2.c: Add exception to -Wunreachable-code.
	* grub-core/loader/ia64/efi/linux.c: Add exception to -Wcast-align.
	* grub-core/loader/mips/linux.c: Likewise.
	* grub-core/loader/multiboot_elfxx.c: Likewise.
	* grub-core/script/parser.y: Add exception to -Wunreachable-code.
	* grub-core/video/sm712.c: Add exception to -Wcast-align.
	* util/import_gcry.py: Add -Wno-cast-align to modules checked by hand.
	* grub-core/font/font.c (grub_font_loader_init): Add explicit cast and
	fixme.
	* grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Likewise.
	* grub-core/kern/i386/multiboot_mmap.c (grub_machine_mmap_init):
	Fix prototype.
2012-02-10 16:48:48 +01:00
Vladimir 'phcoder' Serbinenko 4f96abd198 * grub-core/script/lexer.c (grub_script_lexer_init): Rename getline
to arg_getline to avoid shadowing.
2012-02-10 12:25:27 +01:00
Vladimir 'phcoder' Serbinenko b525fd834d Clarify and unify messages.
* grub-core/commands/hashsum.c (options): Unify messages.
	* grub-core/commands/keystatus.c (GRUB_MOD_INIT): Don't mark a
	literal-only message as translatable.
	* grub-core/commands/lsacpi.c (GRUB_MOD_INIT): Likewise.
	* grub-core/loader/ia64/efi/linux.c (GRUB_MOD_INIT): Likewise.
	* grub-core/commands/legacycfg.c (GRUB_MOD_INIT): Add quoting around
	commands.
	* grub-core/commands/menuentry.c (options): Clarify that it's a keyboard
	key, not the key used to unlock. Clarify what it's used for.
	* grub-core/kern/emu/hostdisk.c (read_device_map): Unify error message.
	* grub-core/loader/xnu.c (grub_xnu_load_driver): Remove erroneous colon.
	* grub-core/script/main.c (GRUB_MOD_INIT): Clarify [n] to be [NUM].
	* util/grub-editenv.c (options): Unify "verbose" message.
	* util/grub-fstest.c (read_file): Unify error message.
	(fstest): Add quotes around commands.
	(options): Unify "verbose" message.
	* util/grub-install.in: Add quotes around variable name.
	* util/grub-kbdcomp.in: Unify error message.
	* util/grub-mkfont.c (main): Likewise.
	* util/grub-mkrescue.in: Likewise.
	* util/grub-mklayout.c (options): Unify "verbose" message.
	* util/grub-mkstandalone.in: Unify help and verbose messages.
	* util/grub-mount.c (options): Unify "verbose" message.
	* util/grub-probe.c (options): Likewise.
	* util/grub-script-check.c (options): Likewise.
	* util/grub-setup.c (setup): Unify no-terminator message.
	(options): Use DEVICE and not DEV.
	Unify "verbose" message.
	* util/ieee1275/ofpath.c (xrealpath): Unify error message.
2012-02-05 11:23:47 +01:00
Vladimir 'phcoder' Serbinenko 1e5ec32f2d * grub-core/script/execute.c (grub_script_return): Fix warning. 2012-02-04 12:21:21 +01:00
Vladimir 'phcoder' Serbinenko ac576cde1d * grub-core/script/execute.c (grub_script_return): Fix potential
NULL-dereference.
	Reported by: Jim Meyering.
2012-02-04 11:52:10 +01:00
Vladimir 'phcoder' Serbinenko 4a9f8346c9 * grub-core/commands/ls.c: Gettextize.
* grub-core/commands/setpci.c: Likewise.
        * grub-core/commands/videotest.c: Likewise.
        * grub-core/disk/geli.c: Likewise.
        * grub-core/kern/mm.c: Likewise.
        * grub-core/lib/relocator.c: Likewise.
        * grub-core/loader/efi/appleloader.c: Likewise.
        * grub-core/loader/i386/xnu.c: Likewise.
        * grub-core/loader/ia64/efi/linux.c: Likewise.
        * grub-core/loader/xnu.c: Likewise.
        * grub-core/net/dns.c: Likewise.
        * grub-core/net/net.c: Likewise.
        * grub-core/script/lexer.c: Likewise.
        * grub-core/script/parser.y: Likewise.
        * grub-core/script/yylex.l: Likewise.
        * util/getroot.c: Likewise.
        * util/grub-setup.c: Likewise.
2012-02-03 11:56:49 +01:00
Vladimir 'phcoder' Serbinenko 9c2710789f Eliminate grub_min/grub_max prone to overflow usage.
* grub-core/bus/usb/usbhub.c (grub_usb_add_hub): Eliminate grub_min.
	(poll_nonroot_hub): Likewise.
	* grub-core/fs/affs.c (grub_affs_iterate_dir): Likewise.
	(grub_affs_label): Likewise.
	* grub-core/fs/btrfs.c (grub_btrfs_lzo_decompress): Likewise.
	* grub-core/fs/hfs.c (grub_hfs_dir): Likewise.
	(grub_hfs_label): Likewise.
	* grub-core/fs/hfsplus.c (grub_hfsplus_cmp_catkey): Likewise.
	* grub-core/fs/zfs/zfs.c (MIN): Remove.
	(zap_leaf_array_equal): Use grub_size. Remove MIN.
	(zap_leaf_array_get): Likewise.
	(dnode_get_path): Likewise.
	* grub-core/io/lzopio.c (grub_lzopio_read): Eliminate grub_min.
	* grub-core/io/xzio.c (grub_xzio_read): Likewise.
	* grub-core/script/execute.c (grub_script_break): Likewise.
	* grub-core/script/lexer.c (grub_script_lexer_record): Eliminate
	grub_max.
	* grub-core/script/yylex.l (grub_lexer_yyrealloc): Likewise.
	* include/grub/misc.h (grub_min): Removed.
	(grub_max): Likewise.
2012-01-14 15:44:34 +01:00
Vladimir 'phcoder' Serbinenko 4d8c476536 Avoid cutting in the middle of UTF-8 string.
* include/grub/charset.h (grub_getend): New function.
	* grub-core/script/function.c (grub_script_function_find): Use
	grub_getend.
	* grub-core/normal/completion.c (add_completion): Likewise.
2011-12-25 16:11:41 +01:00
Vladimir 'phcoder' Serbinenko d35d0d3753 Add const keyword to grub_env_get and gettextize week days.
* grub-core/hook/datehook.c (grub_datetime_names): Make const.
	(grub_read_hook_datetime): Return const char *.
	* grub-core/kern/env.c (grub_env_get): Return const char *. All users
	updated.
	* grub-core/normal/datetime.c (grub_weekday_names): Make const.
	Mark for gettext.
	(grub_get_weekday_name): Return const char *. Call gettext.
	* grub-core/script/argv.c (grub_script_argv_append): Receive const
	char * and len as the argument. All users updated.
	(grub_script_argv_split_append): Receive const char *.
	* include/grub/datetime.h (grub_get_weekday_name): Update proto.
	* include/grub/env.h (grub_env_get): Likewise.
	(grub_env_read_hook_t): Return const char *.
	* include/grub/script_sh.h (grub_script_argv_append): Update proto.
	(grub_script_argv_split_append): Likewise.
2011-11-11 20:34:37 +01:00
Vladimir 'phcoder' Serbinenko 124df5f6ca Fine grainely disable warnings on lexer. Remove Wno-error on it.
* grub-core/Makefile.core.def (normal): Remove -Wno-error.
	* grub-core/script/lexer.c: Declare yytext_ptr to avoid having
	yylex_strncpy.
	* grub-core/script/yylex.l: Add fine-grained #pragma.
2011-10-23 23:32:06 +02:00