Handle missing UUID/LABEL from blkid.

Bug: 11627785
Change-Id: Iee757abbc3795234f41d513a6aed8ad33855cb7a
This commit is contained in:
Jeff Sharkey 2013-11-11 14:46:39 -08:00
parent cc21d6ea58
commit 6bcd362edd

View file

@ -668,15 +668,15 @@ int Volume::extractMetadata(const char* devicePath) {
if (fgets(line, sizeof(line), fp) != NULL) {
ALOGD("blkid identified as %s", line);
char* start = strstr(line, "UUID=") + 5;
if (sscanf(start, "\"%127[^\"]\"", value) == 1) {
char* start = strstr(line, "UUID=");
if (start != NULL && sscanf(start + 5, "\"%127[^\"]\"", value) == 1) {
setUuid(value);
} else {
setUuid(NULL);
}
start = strstr(line, "LABEL=") + 6;
if (sscanf(start, "\"%127[^\"]\"", value) == 1) {
start = strstr(line, "LABEL=");
if (start != NULL && sscanf(start + 6, "\"%127[^\"]\"", value) == 1) {
setUserLabel(value);
} else {
setUserLabel(NULL);