Diff between 9f14800ff3ff8bdaa38f74387c38f193bf1414b4 and 1c58c18eaaebce43528617fdd439a4ccf56e1496

Changed Files

File Additions Deletions Status
lib/bluetooth.c +8 -8 modified

Full Patch

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index f51e310..a1b4c13 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -88,18 +88,18 @@ int ba2str(const bdaddr_t *ba, char *str)
 
 int str2ba(const char *str, bdaddr_t *ba)
 {
-	uint8_t b[6];
-	const char *ptr = str;
+	bdaddr_t b;
 	int i;
 
-	for (i = 0; i < 6; i++) {
-		b[i] = (uint8_t) strtol(ptr, NULL, 16);
-		if (i != 5 && !(ptr = strchr(ptr, ':')))
-			ptr = ":00:00:00:00:00";
-		ptr++;
+	if (bachk(str) < 0) {
+		memset(ba, 0, sizeof(*ba));
+		return -1;
 	}
 
-	baswap(ba, (bdaddr_t *) b);
+	for (i = 0; i < 6; i++, str += 3)
+		b.b[i] = strtol(str, NULL, 16);
+
+	baswap(ba, &b);
 
 	return 0;
 }