Improve gettext support. Stylistic fixes and error handling fixes while

on it.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-08 19:26:01 +01:00
parent 215c90cb82
commit 9c4b5c13e6
184 changed files with 1175 additions and 959 deletions

View file

@ -42,6 +42,7 @@
#include <grub/file.h>
#include <grub/dl.h>
#include <grub/deflate.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -193,10 +194,7 @@ test_gzip_header (grub_file_t file)
if (grub_file_read (gzio->file, &hdr, 10) != 10
|| ((hdr.magic != GZIP_MAGIC)
&& (hdr.magic != OLD_GZIP_MAGIC)))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no gzip magic found");
return 0;
}
return 0;
/*
* This does consistency checking on the header data. If a
@ -211,10 +209,7 @@ test_gzip_header (grub_file_t file)
grub_le_to_cpu16 (extra_len))))
|| ((hdr.flags & ORIG_NAME) && eat_field (gzio->file, -1))
|| ((hdr.flags & COMMENT) && eat_field (gzio->file, -1)))
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "unsupported gzip format");
return 0;
}
return 0;
gzio->data_offset = grub_file_tell (gzio->file);
@ -222,10 +217,7 @@ test_gzip_header (grub_file_t file)
{
grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
return 0;
}
return 0;
/* FIXME: this does not handle files whose original size is over 4GB.
But how can we know the real original size? */
file->size = grub_le_to_cpu32 (orig_len);
@ -402,7 +394,7 @@ gzio_seek (grub_gzio_t gzio, grub_off_t off)
{
if (off > gzio->mem_input_size)
grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to seek outside of the file");
N_("attempt to seek outside of the file"));
else
gzio->mem_input_off = off;
}
@ -1158,10 +1150,10 @@ grub_gzio_open (grub_file_t io)
if (! test_gzip_header (file))
{
grub_errno = GRUB_ERR_NONE;
grub_free (gzio);
grub_free (file);
grub_file_seek (io, 0);
grub_errno = GRUB_ERR_NONE;
return io;
}

View file

@ -299,31 +299,17 @@ test_header (grub_file_t file)
grub_uint8_t *name = NULL;
if (grub_file_read (lzopio->file, &header, sizeof (header)) != sizeof (header))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no lzop magic found");
return 0;
}
return 0;
if (grub_memcmp (header.magic, LZOP_MAGIC, LZOP_MAGIC_SIZE) != 0)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no lzop magic found");
return 0;
}
return 0;
if (grub_be_to_cpu16(header.lib_version) < LZOP_NEW_LIB)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"unsupported (too old) LZOP version");
return 0;
}
return 0;
/* Too new version, should upgrade minilzo? */
if (grub_be_to_cpu16 (header.lib_version_ext) > MINILZO_VERSION)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"unsupported (too new) LZO version");
return 0;
}
return 0;
flags = grub_be_to_cpu32 (header.flags);
@ -417,8 +403,6 @@ test_header (grub_file_t file)
return 1;
CORRUPTED:
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "lzop file corrupted");
grub_free(name);
return 0;

View file

@ -98,24 +98,15 @@ test_header (grub_file_t file)
STREAM_HEADER_SIZE);
if (xzio->buf.in_size != STREAM_HEADER_SIZE)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no xz magic found");
return 0;
}
return 0;
ret = xz_dec_run (xzio->dec, &xzio->buf);
if (ret == XZ_FORMAT_ERROR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no xz magic found");
return 0;
}
return 0;
if (ret != XZ_OK)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "not supported xz options");
return 0;
}
return 0;
return 1;
}
@ -174,7 +165,6 @@ test_footer (grub_file_t file)
return 1;
ERROR:
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "bad footer magic");
return 0;
}