[Spice-devel] [PATCH spice-server 04/33] Avoids %m in formatting for Windows

Frediano Ziglio fziglio at redhat.com
Fri Dec 21 12:02:52 UTC 2018


Not supported.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
--
TODO find a better solution
---
 server/reds.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server/reds.c b/server/reds.c
index aa3f8ca7..2874bd4c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3582,7 +3582,14 @@ static const char* parse_next_video_codec(const char *codecs, char **encoder,
     }
     int n;
     *encoder = *codec = NULL;
+#ifndef _WIN32
     if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec, &n) == 2) {
+#else
+    char encoder_buf[130], codec_buf[130];
+    if (sscanf(codecs, "%128[0-9a-zA-Z_]:%128[0-9a-zA-Z_]%n", encoder_buf, codec_buf, &n) == 2) {
+        *encoder = strdup(encoder_buf);
+        *codec = strdup(codec_buf);
+#endif
         // this avoids accepting "encoder:codec" followed by garbage like "$%*"
         if (codecs[n] != ';' && codecs[n] != '\0') {
             free(*codec);
-- 
2.17.2



More information about the Spice-devel mailing list