kib/uuid.c: add check for length for uuid_is_valid
Subsystems (2)
PATCH 1/1 kib/uuid.c: add check for length for uuid_is_valid
Add check for length strict equality for uuid is valid
Signed-off-by Alexander Pantyukhin <[email protected]>
--- lib/test_uuid.c | 1 + lib/uuid.c | 3 +++ 2 files changed, 4 insertions(+)
lib/test_uuid.c +1 -0
@@ -37,6 +37,7 @@ static const char * const test_uuid_wrong_data[] = {"c33f4995-3701-450e-9fbf206a2e98e576 " ,/* no hyphen(s) */ "64b4371c-77c1-48f9-8221-29f054XX023b" ,/* invalid character(s) */ "0cb4ddff-a545-4401-9d06-688af53e" ,/* not enough data */ + "0cb4ddff-a545-4401-9d06-688af53e7f8412" /* too much data */ };static unsigned total_tests__initdata ;
lib/uuid.c +3 -0
@@ -89,6 +89,9 @@ bool uuid_is_valid(const char *uuid) {unsigned int i; +if (strlen (uuid) !=UUID_STRING_LEN ) +return false; +for (i =0 ; i <UUID_STRING_LEN ; i++) {if (i ==8 || i ==13 || i ==18 || i ==23 ) {if (uuid[i] !='-' )
Signature · 1 line
2.25.1
Andy Shevchenko
reviewerOn Sat, Jan 21, 2023 at 02:38:02AM +0500, Alexander Pantyukhin wrote:
Thank you for the patch.
Quoted 1 line
Add check for length strict equality for uuid is valid
UUID
Missing period at the end of sentence.
...
Why do you think it's a problem?
Have you checked all callers if they strictly using this API and not to parse something like:
UUID ...other data...\0
?
Signature · 2 lines
With Best Regards, Andy Shevchenko