Validate input string length

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

View File

@ -676,8 +676,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] == '*')
{
@ -689,9 +694,9 @@ extractTopComment(const char *inputString)
}
}
if (i > 2)
if (i > commentStartCharsLength)
{
return get_substring(inputString, 2, i);
return get_substring(inputString, commentStartCharsLength, i);
}
else
{