bugfix: stack-buffer-overflow (#19584)
This commit is contained in:
parent
e11d57d58c
commit
e92bf83986
|
@ -834,7 +834,11 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
|||
uuid_generate(uuid);
|
||||
// it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null
|
||||
uuid_unparse_lower(uuid, buf);
|
||||
memcpy(uid, buf, uidlen);
|
||||
int n = snprintf(uid, uidlen, "%.*s", (int)sizeof(buf), buf); // though less performance, much safer
|
||||
if (n >= uidlen) {
|
||||
// target buffer is too small
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
int len = 0;
|
||||
|
|
Loading…
Reference in New Issue