Skip to content

Commit

Permalink
Add boundary checks for string modification
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Owen <[email protected]>
  • Loading branch information
Jake Owen committed Aug 7, 2024
1 parent b3f2054 commit b11964b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contrib/babelfishpg_tsql/src/pl_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -4283,9 +4283,9 @@ static void bbf_func_ext_update_proc_definition(Oid oid)
}
appendStringInfoChar(&infoSchemaStr, original_query[i]);
}
else if(original_query[i] == '/' && original_query[i + 1] == '*' && i < strlen(original_query))
else if(i + 1 < strlen(original_query) && original_query[i] == '/' && original_query[i + 1] == '*')
{
while(original_query[i] != '*' && original_query[i+1] != '/')
while(i + 1 < strlen(original_query) && original_query[i] != '*' && original_query[i+1] != '/')
{
appendStringInfoChar(&infoSchemaStr, original_query[i]);
i++;
Expand All @@ -4294,7 +4294,7 @@ static void bbf_func_ext_update_proc_definition(Oid oid)
appendStringInfoChar(&infoSchemaStr, original_query[i+1]);
i++;
}
else if(strncasecmp(original_query + i, "alter", 5) == 0)
else if(i + 5 < strlen(original_query) && strncasecmp(original_query + i, "alter", 5) == 0)
{
// Change alter to create, add rest of characters, and update
appendStringInfoString(&infoSchemaStr, "CREATE");
Expand Down

0 comments on commit b11964b

Please sign in to comment.