From: Jon McCune <jonmccune@google.com>
To: grub-devel@gnu.org
Cc: Jon McCune <jonmccune@google.com>
Subject: [PATCH v1 1/2] make check_blocklists() not depend on an envblk data type
Date: Mon, 26 Aug 2013 12:29:05 -0700 [thread overview]
Message-ID: <1377545346-23642-2-git-send-email-jonmccune@google.com> (raw)
In-Reply-To: <1377545346-23642-1-git-send-email-jonmccune@google.com>
Signed-off-by: Jon McCune <jonmccune@google.com>
This is a small patch that makes check_blocklists() more generally useful,
and facilitates the next patch.
---
grub-core/commands/loadenv.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
index c0a42c5..691d163 100644
--- a/grub-core/commands/loadenv.c
+++ b/grub-core/commands/loadenv.c
@@ -202,7 +202,7 @@ free_blocklists (struct blocklist *p)
}
static grub_err_t
-check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
+check_blocklists (const char* expected_file_data, struct blocklist *blocklists,
grub_file_t file)
{
grub_size_t total_length;
@@ -210,7 +210,6 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
grub_disk_t disk;
grub_disk_addr_t part_start;
struct blocklist *p;
- char *buf;
/* Sanity checks. */
total_length = 0;
@@ -243,7 +242,6 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
part_start = grub_partition_get_start (disk->partition);
- buf = grub_envblk_buffer (envblk);
for (p = blocklists, index = 0; p; index += p->length, p = p->next)
{
char blockbuf[GRUB_DISK_SECTOR_SIZE];
@@ -252,7 +250,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
p->offset, p->length, blockbuf))
return grub_errno;
- if (grub_memcmp (buf + index, blockbuf, p->length) != 0)
+ if (grub_memcmp (expected_file_data + index, blockbuf, p->length) != 0)
return grub_error (GRUB_ERR_FILE_READ_ERROR, "invalid blocklist");
}
@@ -350,7 +348,7 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
if (! envblk)
goto fail;
- if (check_blocklists (envblk, ctx.head, file))
+ if (check_blocklists (grub_envblk_buffer (envblk), ctx.head, file))
goto fail;
while (argc)
--
1.8.3
next prev parent reply other threads:[~2013-08-26 19:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-26 19:29 [PATCH v1 0/2] New commands: load_env_untrusted, save_env_untrusted Jon McCune
2013-08-26 19:29 ` Jon McCune [this message]
2013-08-26 19:29 ` [PATCH v1 2/2] introduce new commands load_env_untrusted and save_env_untrusted: Jon McCune
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377545346-23642-2-git-send-email-jonmccune@google.com \
--to=jonmccune@google.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).