From b1d2f96823e92128a70f425a467b0b4d2655caa7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 22 Apr 2021 17:43:38 +0100 Subject: [PATCH] sesschan.c: use dupprintf in place of snprintf. I hadn't actually realised until now that the SSH server code is now being compiled on Windows! It happened because I've been using static libraries internally to the build organisation: of course, CMake has no way of knowing that those libraries are only needed _within_ the build, and for all it knows they might be end products shipped to users to link their own applications with. So all the objects in the 'sshserver' library will now be compiled, even on Windows, where no applications actually link with it. And in that context, the use of snprintf caused a compiler warning from the w32old build, because there, snprintf doesn't exist in the older version of the C library. Of course, it's currently benign, because no application in the w32old build (or any other Windows build) is actually linking again the sshserver library. But I don't want to rule it out in future, or at least not for a trivial reason like this. So I've fixed the warning in the simplest way, by switching to our own dupprintf, which is available everywhere. --- sesschan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sesschan.c b/sesschan.c index 0cf85b3b..4ab709da 100644 --- a/sesschan.c +++ b/sesschan.c @@ -400,13 +400,10 @@ bool sesschan_enable_x11_forwarding( sesschan *sess = container_of(chan, sesschan, chan); strbuf *authdata_bin; size_t i; - char screensuffix[32]; if (oneshot) return false; /* not supported */ - snprintf(screensuffix, sizeof(screensuffix), ".%u", screen_number); - /* * Decode the authorisation data from ASCII hex into binary. */ @@ -430,11 +427,14 @@ bool sesschan_enable_x11_forwarding( sess->xfwd_plug.vt = &xfwd_plugvt; + char *screensuffix = dupprintf(".%u", screen_number); + sess->n_x11_sockets = platform_make_x11_server( &sess->xfwd_plug, appname, 10, screensuffix, authproto, ptrlen_from_strbuf(authdata_bin), sess->x11_sockets, sess->conf); + sfree(screensuffix); strbuf_free(authdata_bin); return sess->n_x11_sockets != 0; }