validate dblink conn: prevent acess to unknown addresses

This commit is contained in:
wuyuechuan
2023-09-16 15:04:47 +08:00
parent 52794627de
commit c4bd5e9098

View File

@ -974,10 +974,10 @@ Datum dblink_open(PG_FUNCTION_ARGS)
rconn = getConnectionByName(conname);
}
linker = rconn->linker;
if (linker == NULL) {
if (rconn == NULL || rconn->linker == NULL) {
DBLINK_CONN_NOT_AVAIL;
}
linker = rconn->linker;
/* Assemble sql */
appendStringInfo(&buf, "DECLARE %s CURSOR FOR %s", curname, sql);
@ -1028,10 +1028,10 @@ Datum dblink_close(PG_FUNCTION_ARGS)
rconn = getConnectionByName(conname);
}
linker = rconn->linker;
if (linker == NULL) {
if (rconn == NULL || rconn->linker == NULL) {
DBLINK_CONN_NOT_AVAIL;
}
linker = rconn->linker;
appendStringInfo(&buf, "CLOSE %s", curname);
@ -3113,4 +3113,4 @@ static void storeRowInit(storeInfo* sinfo, int nfields, bool first)
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
}
}
}