X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/4191cb150300d310ab5fa22ce2cfb02b6f6051b0..481eeb93961ef9998901c522b498253d75124fb4:/src/src/lookups/ldap.c diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c index 6065d2b8e..b93782cc3 100644 --- a/src/src/lookups/ldap.c +++ b/src/src/lookups/ldap.c @@ -2,9 +2,10 @@ * Exim - an Internet mail transport agent * *************************************************/ +/* Copyright (c) The Exim Maintainers 2020 - 2023 */ /* Copyright (c) University of Cambridge 1995 - 2018 */ -/* Copyright (c) The Exim Maintainers 2020 - 2021 */ /* See the file NOTICE for conditions of use and distribution. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* Many thanks to Stuart Lynne for contributing the original code for this driver. Further contributions from Michael Haardt, Brian Candler, Barry @@ -325,17 +326,19 @@ if (!lcp) g = string_catn(NULL, ldap_url, init_ptr - ldap_url); g = string_fmt_append(g, "//%s:%d/", shost, port); } - string_from_gstring(g); /* Call ldap_initialize() and check the result */ + { + const uschar * s = string_from_gstring(g); - DEBUG(D_lookup) debug_printf_indent("ldap_initialize with URL %s\n", g->s); - if ((rc = ldap_initialize(&ld, CS g->s)) != LDAP_SUCCESS) - { - *errmsg = string_sprintf("ldap_initialize: (error %d) URL \"%s\"\n", - rc, g->s); - goto RETURN_ERROR; - } + DEBUG(D_lookup) debug_printf_indent("ldap_initialize with URL %s\n", s); + if ((rc = ldap_initialize(&ld, CS s)) != LDAP_SUCCESS) + { + *errmsg = string_sprintf("ldap_initialize: (error %d) URL \"%s\"\n", + rc, s); + goto RETURN_ERROR; + } + } store_reset(reset_point); /* Might as well save memory when we can */ @@ -1519,8 +1522,8 @@ else { if (Ustrchr(LDAP_DN_QUOTE, c) != NULL) { - Ustrncpy(t, US"%5C", 3); /* insert \ where needed */ - t += 3; /* fall through to check URL */ + memcpy(t, US"%5C", 3); /* insert \ where needed */ + t += 3; /* fall through to check URL */ } if (Ustrchr(URL_NONQUOTE, c) == NULL) /* e.g. ] => %5D */ { @@ -1534,9 +1537,9 @@ else /* Handle the trailing spaces */ - while (*ss++ != 0) + while (*ss++) { - Ustrncpy(t, US"%5C%20", 6); + memcpy(t, US"%5C%20", 6); t += 6; } }