0001-Don-t-use-strcmp-with-nullable-pointers.patch
text/x-patch
Filename: 0001-Don-t-use-strcmp-with-nullable-pointers.patch
Type: text/x-patch
Part: 0
Message:
Don't pass NULL pointer to strcmp().
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Don't use strcmp() with nullable pointers.
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc.c | 3 | 1 |
From dcd7a49190f0e19ba0a1e697cac45724450f6365 Mon Sep 17 00:00:00 2001
From: Xing Guo <higuoxing@gmail.com>
Date: Wed, 1 Nov 2023 16:41:49 +0800
Subject: [PATCH] Don't use strcmp() with nullable pointers.
Passing a NULL pointer to strcmp() is an undefined behavior. It can make
the PostgreSQL server crash. This patch helps fix it.
---
src/backend/utils/misc/guc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 39d3775e80..b277c48925 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -5255,7 +5255,9 @@ get_explain_guc_options(int *num)
{
struct config_string *lconf = (struct config_string *) conf;
- modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
+ modified = (lconf->boot_val == NULL ||
+ *lconf->variable == NULL ||
+ strcmp(lconf->boot_val, *(lconf->variable)) != 0);
}
break;
--
2.42.0