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

Unified Diff: cgpt/cmd_find.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_create.c ('k') | cgpt/cmd_show.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cgpt/cmd_find.c
diff --git a/cgpt/cmd_find.c b/cgpt/cmd_find.c
index 403d40f2f506276a735fd8e0502644b073af0f46..e8fe9b319aeee041093c7acae283f58d07928449 100644
--- a/cgpt/cmd_find.c
+++ b/cgpt/cmd_find.c
@@ -160,7 +160,7 @@ static int do_search(char *filename) {
int i;
struct drive drive;
GptEntry *entry;
- char partlabel[sizeof(entry->name) * 3 / 2];
+ char partlabel[GPT_PARTNAME_LEN];
if (CGPT_OK != DriveOpen(filename, &drive))
return 0;
@@ -181,7 +181,8 @@ static int do_search(char *filename) {
(set_type && !memcmp(&type_guid, &entry->type, sizeof(Guid)))) {
found = 1;
} else if (set_label) {
- UTF16ToUTF8(entry->name, (uint8_t *)partlabel);
+ UTF16ToUTF8(entry->name, sizeof(entry->name) / sizeof(entry->name[0]),
+ (uint8_t *)partlabel, sizeof(partlabel));
if (!strncmp(label, partlabel, sizeof(partlabel))) {
found = 1;
}
@@ -250,7 +251,7 @@ static char *is_wholedev(const char *basename) {
static int scan_real_devs(void) {
int found = 0;
char line[BUFSIZE];
- char partname[128];
+ char partname[128]; // max size for /proc/partition lines?
FILE *fp;
char *pathname;
@@ -264,7 +265,7 @@ static int scan_real_devs(void) {
int ma, mi;
long long unsigned int sz;
- if (sscanf(line, " %d %d %llu %128[^\n ]", &ma, &mi, &sz, partname) != 4)
+ if (sscanf(line, " %d %d %llu %127[^\n ]", &ma, &mi, &sz, partname) != 4)
continue;
if ((pathname = is_wholedev(partname))) {
« no previous file with comments | « cgpt/cmd_create.c ('k') | cgpt/cmd_show.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698