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

Unified Diff: cgpt/cmd_add.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/cgpt_common.c ('k') | cgpt/cmd_boot.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cgpt/cmd_add.c
diff --git a/cgpt/cmd_add.c b/cgpt/cmd_add.c
index 12ae57c98edd7381229fc0e9b789f826ae7c5840..21085e71444a8fd896e697791356cf2b21ef7e91 100644
--- a/cgpt/cmd_add.c
+++ b/cgpt/cmd_add.c
@@ -36,7 +36,7 @@ static void Usage(void)
int cmd_add(int argc, char *argv[]) {
struct drive drive;
- int partition = 0;
+ uint32_t partition = 0;
uint64_t begin = 0;
uint64_t size = 0;
Guid type_guid;
@@ -57,8 +57,8 @@ int cmd_add(int argc, char *argv[]) {
int gpt_retval;
GptEntry *entry;
- int index;
-
+ uint32_t index;
+
int c;
int errorcnt = 0;
char *e = 0;
@@ -198,7 +198,7 @@ int cmd_add(int argc, char *argv[]) {
return CGPT_FAILED;
}
- int max_part = GetNumberOfEntries(&drive.gpt);
+ uint32_t max_part = GetNumberOfEntries(&drive.gpt);
if (partition) {
if (partition > max_part) {
Error("invalid partition number: %d\n", partition);
@@ -244,9 +244,8 @@ int cmd_add(int argc, char *argv[]) {
if (set_unique)
memcpy(&entry->unique, &unique_guid, sizeof(Guid));
if (label) {
- uint16_t buf[128];
- UTF8ToUTF16((uint8_t *)label, buf);
- memcpy(entry->name, buf, sizeof(entry->name));
+ UTF8ToUTF16((uint8_t *)label, entry->name,
+ sizeof(entry->name) / sizeof(entry->name[0]));
}
if (set_raw) {
entry->attrs.fields.gpt_att = raw_value;
« no previous file with comments | « cgpt/cgpt_common.c ('k') | cgpt/cmd_boot.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698