Skip to content

fix the null pointer dereference#279

Merged
lfittl merged 2 commits intopganalyze:17-latestfrom
QiuYitai:17-latest
Apr 12, 2025
Merged

fix the null pointer dereference#279
lfittl merged 2 commits intopganalyze:17-latestfrom
QiuYitai:17-latest

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