Skip to content

Commit c328502

Browse files
committed
Better uuid format check
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
1 parent b632f3d commit c328502

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/VariableBase.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,11 @@ bool Variable::checkUUIDFormat(void) {
225225
"24."));
226226
return false;
227227
}
228-
for (uint8_t i = 0; i < 36; i++) {
229-
bool isAcceptable = false;
230-
for (uint8_t j = 0; !isAcceptable && j < 23; j++) {
231-
if (_uuid[i] == acceptableChars[j]) {
232-
isAcceptable = true;
233-
j = 23; // Stop the inner loop
234-
}
235-
}
236-
if (!isAcceptable) {
237-
MS_DBG(F("UUID for"), getVarCode(), '(', _uuid, ')',
238-
F("has a bad character"), _uuid[i], F("at"), i + 1);
239-
return false;
240-
}
228+
int first_invalid = strspn(_uuid, acceptableChars);
229+
if (first_invalid != 36) {
230+
MS_DBG(F("UUID for"), getVarCode(), '(', _uuid, ')',
231+
F("has a bad character"), _uuid[i], F("at"), first_invalid);
232+
return false;
241233
}
242234
return true;
243235
}

0 commit comments

Comments
 (0)