Address some security concerns in the cgpt tool.

1. Check for potential integer overflow in sector_bytes * sector_count.
2. Added O_NOFOLLOW to open() call - Is this enough?
3. Passing buffer length to GuidToStr(), PMBRToStr().
4. Use unsigned int in GetEntry() to determine stride.
5. Address conversion between UTF16 and UTF8.

Note: The UTF conversion is complex and troublesome, and needs careful
consideration to get right. For now, I've just forced the interpretation of
the partition name to 7-bit ASCII. That's sufficient for the needs of Chrome
OS, and I can file a new issue to handle UTF correctly.

BUG=chrome-os-partner:705
TEST=manual

Running "make runtests" invokes the tests/run_cgpt_tests.sh script, which checks the behavior and output of the cgpt tool.

Review URL: http://codereview.chromium.org/3594010

Change-Id: I5fd29796d8c929527e0cfbc6d5ccbcdc77502c6b
diff --git a/cgpt/cmd_create.c b/cgpt/cmd_create.c
index 1680370..6dabde3 100644
--- a/cgpt/cmd_create.c
+++ b/cgpt/cmd_create.c
@@ -24,7 +24,7 @@
 int cmd_create(int argc, char *argv[]) {
   struct drive drive;
   int zap = 0;
-  
+
   int c;
   int errorcnt = 0;
 
@@ -76,7 +76,7 @@
          drive.gpt.sector_bytes * GPT_ENTRIES_SECTORS);
   memset(drive.gpt.secondary_entries, 0,
          drive.gpt.sector_bytes * GPT_ENTRIES_SECTORS);
-  
+
   drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 |
                          GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2);