* [PATCH] kib/uuid.c: add check for length for uuid_is_valid
@ 2023-01-20 21:38 Alexander Pantyukhin
2023-01-21 10:50 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Pantyukhin @ 2023-01-20 21:38 UTC (permalink / raw)
To: andriy.shevchenko; +Cc: hch, linux-kernel, Alexander Pantyukhin
Add check for length strict equality for uuid is valid
Signed-off-by: Alexander Pantyukhin <apantykhin@gmail.com>
---
lib/test_uuid.c | 1 +
lib/uuid.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/lib/test_uuid.c b/lib/test_uuid.c
index cd819c397dc7..7a3d258fa695 100644
--- a/lib/test_uuid.c
+++ b/lib/test_uuid.c
@@ -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;
diff --git a/lib/uuid.c b/lib/uuid.c
index e309b4c5be3d..ca10e2b4334b 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -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] != '-')
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kib/uuid.c: add check for length for uuid_is_valid
2023-01-20 21:38 [PATCH] kib/uuid.c: add check for length for uuid_is_valid Alexander Pantyukhin
@ 2023-01-21 10:50 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2023-01-21 10:50 UTC (permalink / raw)
To: Alexander Pantyukhin; +Cc: hch, linux-kernel
On Sat, Jan 21, 2023 at 02:38:02AM +0500, Alexander Pantyukhin wrote:
Thank you for the patch.
> 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
?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-21 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 21:38 [PATCH] kib/uuid.c: add check for length for uuid_is_valid Alexander Pantyukhin
2023-01-21 10:50 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).