Skip to content

fix the null pointer dereference #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2025
Merged

Conversation

QiuYitai
Copy link
Contributor

@QiuYitai QiuYitai commented Apr 2, 2025

The NULL Dereference vulnerability happens in static void deparseAlterIdentityColumnOptionList (), src/postgres_deparse.c
How the NULL Pointer Dereference happens:

  1. When strcmp(def_elem->defname, "generated") == 0 and def_elem->arg == NULL
  2. NULL dereference of variable def_elem->arg happens at (castNode(Integer, v)->ival)
static void deparseAlterIdentityColumnOptionList(StringInfo str, List *l)
{
    ListCell *lc = NULL;
    foreach (lc, l)
    {
        DefElem *def_elem = castNode(DefElem, lfirst(lc));
        ......
        else if (strcmp(def_elem->defname, "generated") == 0)
        {
            appendStringInfoString(str, "SET GENERATED ");
=>          if (intVal(def_elem->arg) == ATTRIBUTE_IDENTITY_ALWAYS)
                appendStringInfoString(str, "ALWAYS");
            ......
        }
    }
    ......
}

=>  #define intVal(v)       (castNode(Integer, v)->ival)

@lfittl
Copy link
Member

lfittl commented Apr 12, 2025

I've made a minor adjustment and will merge this - thanks for making the fix!

@lfittl lfittl merged commit 2e02616 into pganalyze:17-latest Apr 12, 2025
15 checks passed
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.

2 participants