Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Unified Diff: cgpt/cmd_boot.c

Issue 3594010: Address some security concerns in the cgpt tool. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git
Patch Set: A little more cleanup. Take one more look, please. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cgpt/cmd_add.c ('k') | cgpt/cmd_create.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cgpt/cmd_boot.c
diff --git a/cgpt/cmd_boot.c b/cgpt/cmd_boot.c
index 784684a24d404188e880ef6480a15f42dacb2f30..56ab1d580848e89d145e395148d7b153fa849314 100644
--- a/cgpt/cmd_boot.c
+++ b/cgpt/cmd_boot.c
@@ -34,12 +34,12 @@ static void Usage(void)
int cmd_boot(int argc, char *argv[]) {
struct drive drive;
- int partition = 0;
+ uint32_t partition = 0;
char *bootfile = 0;
int create_pmbr = 0;
int retval = 1;
int gpt_retval;
-
+
int c;
int errorcnt = 0;
char *e = 0;
@@ -63,7 +63,7 @@ int cmd_boot(int argc, char *argv[]) {
case 'p':
create_pmbr = 1;
break;
-
+
case 'h':
Usage();
return CGPT_OK;
@@ -98,7 +98,7 @@ int cmd_boot(int argc, char *argv[]) {
Error("Unable to read PMBR\n");
goto done;
}
-
+
if (create_pmbr) {
drive.pmbr.magic[0] = 0x1d;
drive.pmbr.magic[1] = 0x9a;
@@ -131,7 +131,7 @@ int cmd_boot(int argc, char *argv[]) {
goto done;
}
- int index = partition - 1;
+ uint32_t index = partition - 1;
GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index);
memcpy(&drive.pmbr.boot_guid, &entry->unique, sizeof(Guid));
}
@@ -152,9 +152,9 @@ int cmd_boot(int argc, char *argv[]) {
close(fd);
}
-
- char buf[256];
- GuidToStr(&drive.pmbr.boot_guid, buf);
+
+ char buf[GUID_STRLEN];
+ GuidToStr(&drive.pmbr.boot_guid, buf, sizeof(buf));
printf("%s\n", buf);
// Write it all out
« no previous file with comments | « cgpt/cmd_add.c ('k') | cgpt/cmd_create.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698