Skip to content

Fix Oid signed overflow in format strings producing negative values#382

Open
sfc-gh-npuka wants to merge 1 commit into
mainfrom
naisila/fix_oid_signed
Open

Fix Oid signed overflow in format strings producing negative values#382
sfc-gh-npuka wants to merge 1 commit into
mainfrom
naisila/fix_oid_signed

Conversation

@sfc-gh-npuka

Copy link
Copy Markdown
Collaborator

Oid is unsigned int, but several format strings used %d (signed) instead of %u, causing OIDs above INT_MAX to appear negative in S3 paths, sequence names, and temp table names.

Oid is unsigned int, but several format strings used %d (signed)
instead of %u, causing OIDs above INT_MAX to appear negative in
S3 paths, sequence names, and temp table names.

Signed-off-by: sfc-gh-npuka <naisila.puka@snowflake.com>
const char *relationName = GetRestCatalogTableName(relationId);

appendStringInfo(location, "%s/%s/%s/%s/%d", IcebergDefaultLocationPrefix, catalogName, namespaceName, relationName, relationId);
appendStringInfo(location, "%s/%s/%s/%s/%u", IcebergDefaultLocationPrefix, catalogName, namespaceName, relationName, relationId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two questions:

  • Would this break existing tables
  • Can we add a test? We should be able to get the location of the table from the REST catalog and make sure the OID is non-negative value

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this determines location at create time, right? so wouldn't affect existing tables

RowIdSequenceGetRangeVar(Oid relationId)
{
char *sequenceName = psprintf("rowid_%d_seq", relationId);
char *sequenceName = psprintf("rowid_%u_seq", relationId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this break existing tables with row-ids?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants