Commit 21d8a78fbc for freeswitch.com

commit 21d8a78fbcdb303f9bb03155631a2ed963fdca8a
Author: Dmitry Verenitsin <morbit85@gmail.com>
Date:   Sat Aug 8 22:06:17 2026 +0500

    Merge commit from fork

    `get_display_name_from_contact()` copied the SIP Contact display-name
    into the caller's fixed 512-byte `remote_display_buf` with an unbounded
    `strcpy`, so a stored dialog row with an over-long Contact could
    overflow the stack buffer when a `dialog`-package SUBSCRIBE runs the
    probe.

    Thread the destination size into the helper and copy with
    `switch_copy_string()`. Guard the helper against a zero
    `dst_size` and a `NULL` or empty input, and always null-terminate the
    destination.

diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c
index 6108cc5a6a..c78f4579ac 100644
--- a/src/mod/endpoints/mod_sofia/sofia_presence.c
+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c
@@ -1896,7 +1896,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
 	return 0;
 }

-char *get_display_name_from_contact(const char *in, char* dst)
+char *get_display_name_from_contact(const char *in, char* dst, size_t dst_size)
 {
 	// name-addr      =  [ display-name ] LAQUOT addr-spec RAQUOT
 	// display-name   =  *(token LWS)/ quoted-string
@@ -1904,8 +1904,13 @@ char *get_display_name_from_contact(const char *in, char* dst)
 	char *p;
 	char *buf;

-	strcpy(dst, "");
-	if (strchr(in, '<') && strchr(in, '>')) {
+	if (!dst || !dst_size) {
+		return dst;
+	}
+
+	*dst = '\0';
+
+	if (!zstr(in) && strchr(in, '<') && strchr(in, '>')) {
 		buf = strdup(in);
 		switch_assert(buf);
 		p = strchr(buf, '<');
@@ -1918,11 +1923,11 @@ char *get_display_name_from_contact(const char *in, char* dst)
 						char *q = strdup(p + 1);
 						switch_assert(q);
 						end_of(q) = '\0';
-						strcpy(dst, q);
+						switch_copy_string(dst, q, dst_size);
 						switch_safe_free(q);
 					}
 				} else {
-					strcpy(dst, p);
+					switch_copy_string(dst, p, dst_size);
 				}
 				switch_safe_free(p);
 			}
@@ -2059,7 +2064,7 @@ static int sofia_dialog_probe_callback(void *pArg, int argc, char **argv, char *
 	}
 	else if (bInternal) {
 		local_user = to_user;
-		get_display_name_from_contact(contact, remote_display_buf);
+		get_display_name_from_contact(contact, remote_display_buf, sizeof(remote_display_buf));
 		buf_to_free = sofia_glue_strip_uri(contact);
 		remote_uri = buf_to_free;
 		remote_user = contact_user;