Validate input string length

pull/6753/head
Gokhan Gulbiz 2023-03-13 12:44:57 +03:00
parent c7af2ff0ef
commit 0de2ebad3f
No known key found for this signature in database
GPG Key ID: 608EF06B6BD1B45B
1 changed files with 8 additions and 3 deletions

View File

@ -585,8 +585,13 @@ MultiTenantMonitorshmemSize(void)
static char *
extractTopComment(const char *inputString)
{
int i = 0;
int commentStartCharsLength = 2;
if (strlen(inputString) < commentStartCharsLength )
{
return NULL;
}
int i = 0;
/* If query starts with a comment */
if (inputString[i] == '/' && inputString[i + 1] == '*')
{
@ -598,9 +603,9 @@ extractTopComment(const char *inputString)
}
}
if (i > 2)
if (i > commentStartCharsLength)
{
return get_substring(inputString, 2, i);
return get_substring(inputString, commentStartCharsLength, i);
}
else
{