From 6270167720c70b765422053089a5faf4ad11f36f Mon Sep 17 00:00:00 2001 From: Jingxian Li Date: Tue, 30 Apr 2024 10:08:02 +0800 Subject: [PATCH] fix a code error when calling strncmp function, in which case the third argument (authmethod - strchr(authmethod, ' ')) may be negative, which is not as expected. --- src/bin/initdb/initdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 30e17bd1d1..17a8df0e29 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -2514,7 +2514,7 @@ check_authmethod_valid(const char *authmethod, const char *const *valid_methods, return; /* with space = param */ if (strchr(authmethod, ' ')) - if (strncmp(authmethod, *p, (authmethod - strchr(authmethod, ' '))) == 0) + if (strncmp(authmethod, *p, (strchr(authmethod, ' ') - authmethod)) == 0) return; } -- 2.37.1.windows.1