aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2013-02-28 10:12:57 -0600
committerJames Bottomley <JBottomley@Parallels.com>2013-02-28 10:12:57 -0600
commit30f2fd6a36d86f823b655561bd465d252caffcf1 (patch)
tree0be7a726f4d12bda4b9c9c4f7cb2d7bb8083c15c
parent4c4a5d90605c3cb1417be40965accbc94cf2bd27 (diff)
downloadefitools-30f2fd6a36d86f823b655561bd465d252caffcf1.tar.gz
guid: return error if str_to_guid() fails
-rw-r--r--include/guid.h2
-rw-r--r--lib/guid.c16
2 files changed, 11 insertions, 7 deletions
diff --git a/include/guid.h b/include/guid.h
index 2b2b6cc..17aa6af 100644
--- a/include/guid.h
+++ b/include/guid.h
@@ -2,7 +2,7 @@
#ifndef BUILD_EFI
const char *guid_to_str(EFI_GUID *guid);
-void str_to_guid(const char *str, EFI_GUID *guid);
+int str_to_guid(const char *str, EFI_GUID *guid);
int compare_guid(EFI_GUID *g1, EFI_GUID *g2);
#endif
diff --git a/lib/guid.c b/lib/guid.c
index 75003e6..e6471a5 100644
--- a/lib/guid.c
+++ b/lib/guid.c
@@ -22,13 +22,17 @@ const char *guid_to_str(EFI_GUID *guid)
return str;
}
-void str_to_guid(const char *str, EFI_GUID *guid)
+int str_to_guid(const char *str, EFI_GUID *guid)
{
- sscanf(str, "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
- &guid->Data1, &guid->Data2, &guid->Data3,
- guid->Data4, guid->Data4 + 1, guid->Data4 + 2,
- guid->Data4 + 3, guid->Data4 + 4, guid->Data4 + 5,
- guid->Data4 + 6, guid->Data4 + 7);
+ int args;
+ args = sscanf(str,
+ "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
+ &guid->Data1, &guid->Data2, &guid->Data3,
+ guid->Data4, guid->Data4 + 1, guid->Data4 + 2,
+ guid->Data4 + 3, guid->Data4 + 4, guid->Data4 + 5,
+ guid->Data4 + 6, guid->Data4 + 7);
+
+ return args != 11;
}
int