Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions contrib/xml2/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ pgxml_parser_init(PgXmlStrictness strictness)
/* Initialize libxml */
xmlInitParser();
Comment thread
leborchuk marked this conversation as resolved.

xmlSubstituteEntitiesDefault(1);
xmlLoadExtDtdDefaultValue = 1;

return xmlerrcxt;
}
Expand Down Expand Up @@ -425,8 +423,9 @@ pgxml_xpath(text *document, xmlChar *xpath, xpath_workspace *workspace)

PG_TRY();
{
workspace->doctree = xmlParseMemory((char *) VARDATA_ANY(document),
docsize);
workspace->doctree = xmlReadMemory((char *) VARDATA_ANY(document),
docsize, NULL, NULL,
XML_PARSE_NOENT);
if (workspace->doctree != NULL)
{
workspace->ctxt = xmlXPathNewContext(workspace->doctree);
Expand Down Expand Up @@ -719,7 +718,9 @@ xpath_table(PG_FUNCTION_ARGS)

/* Parse the document */
if (xmldoc)
doctree = xmlParseMemory(xmldoc, strlen(xmldoc));
doctree = xmlReadMemory(xmldoc, strlen(xmldoc),
NULL, NULL,
XML_PARSE_NOENT);
else /* treat NULL as not well-formed */
doctree = NULL;

Expand Down
10 changes: 6 additions & 4 deletions contrib/xml2/xslt_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ xslt_process(PG_FUNCTION_ARGS)
bool xslt_sec_prefs_error;

/* Parse document */
doctree = xmlParseMemory((char *) VARDATA_ANY(doct),
VARSIZE_ANY_EXHDR(doct));
doctree = xmlReadMemory((char *) VARDATA_ANY(doct),
VARSIZE_ANY_EXHDR(doct), NULL, NULL,
XML_PARSE_NOENT);

if (doctree == NULL)
xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,
"error parsing XML document");

/* Same for stylesheet */
ssdoc = xmlParseMemory((char *) VARDATA_ANY(ssheet),
VARSIZE_ANY_EXHDR(ssheet));
ssdoc = xmlReadMemory((char *) VARDATA_ANY(ssheet),
VARSIZE_ANY_EXHDR(ssheet), NULL, NULL,
XML_PARSE_NOENT);

if (ssdoc == NULL)
xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ log_section "Initial Setup"
execute_cmd sudo rm -rf ${BUILD_DESTINATION} || exit 2
execute_cmd sudo chmod a+w /usr/local || exit 2
execute_cmd sudo mkdir -p ${BUILD_DESTINATION}/lib || exit 2
if [[ "$OS_ID" == "rocky" && "$OS_VERSION" =~ ^(8|9) ]]; then
if [[ "$OS_ID" == "rocky" && "$OS_VERSION" =~ ^(8|9|10) ]]; then
Comment thread
leborchuk marked this conversation as resolved.
execute_cmd sudo cp /usr/local/xerces-c/lib/libxerces-c.so \
/usr/local/xerces-c/lib/libxerces-c-3.3.so \
${BUILD_DESTINATION}/lib || exit 3
Expand Down
2 changes: 1 addition & 1 deletion gpcontrib/gp_stats_collector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROTO_BASES = gpsc_plan gpsc_metrics gpsc_set_service
PROTO_OBJS = $(patsubst %,src/protos/%.pb.o,$(PROTO_BASES))

C_OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c src/*/*.c))
CPP_OBJS = $(patsubst %.cpp,%.o,$(wildcard src/*.cpp src/*/*.cpp))
CPP_OBJS = $(patsubst %.cpp,%.o,$(wildcard src/*.cpp src/log/*.cpp src/memory/*.cpp))
Comment thread
leborchuk marked this conversation as resolved.
OBJS = $(C_OBJS) $(CPP_OBJS) $(PROTO_OBJS)

PG_CXXFLAGS += -Werror -Wall -Wno-unused-but-set-variable -std=c++17 -Isrc/protos -Isrc -Iinclude -DGPBUILD
Expand Down
14 changes: 12 additions & 2 deletions src/backend/utils/adt/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@
#if LIBXML_VERSION >= 20704
#define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
#endif

/*
* libxml2 2.12 decided to insert "const" into the error handler API.
*/
#if LIBXML_VERSION >= 21200
#define PgXmlErrorPtr const xmlError *
#else
#define PgXmlErrorPtr xmlErrorPtr
Comment thread
leborchuk marked this conversation as resolved.
#endif

#endif /* USE_LIBXML */

#include "access/htup_details.h"
Expand Down Expand Up @@ -121,7 +131,7 @@ struct PgXmlErrorContext

static xmlParserInputPtr xmlPgEntityLoader(const char *URL, const char *ID,
xmlParserCtxtPtr ctxt);
static void xml_errorHandler(void *data, xmlErrorPtr error);
static void xml_errorHandler(void *data, PgXmlErrorPtr error);
static void xml_ereport_by_code(int level, int sqlcode,
const char *msg, int errcode);
static void chopStringInfoNewlines(StringInfo str);
Expand Down Expand Up @@ -1762,7 +1772,7 @@ xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg)
* Error handler for libxml errors and warnings
*/
static void
xml_errorHandler(void *data, xmlErrorPtr error)
xml_errorHandler(void *data, PgXmlErrorPtr error)
{
PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data;
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/libpq/fe-secure-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ initialize_SSL(PGconn *conn)
bool have_homedir;
bool have_cert;
bool have_rootcert;
EVP_PKEY *pkey = NULL;

/*
* We'll need the home directory if any of the relevant parameters are
Expand Down Expand Up @@ -1133,6 +1132,7 @@ initialize_SSL(PGconn *conn)
/* Colon, but not in second character, treat as engine:key */
char *engine_str = strdup(conn->sslkey);
char *engine_colon;
EVP_PKEY *pkey;
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

pkey is now declared without initialization. If any error/cleanup path in this scope frees or checks pkey before it’s assigned (or if assignment is conditional), this becomes undefined behavior. Initialize it to NULL at declaration (and keep cleanup logic consistent).

Suggested change
EVP_PKEY *pkey;
EVP_PKEY *pkey = NULL;

Copilot uses AI. Check for mistakes.

if (engine_str == NULL)
{
Expand Down
Loading