mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-07 20:00:20 +00:00
reds: Fix one case parsing invalid codec string
In case we pass something like "spice:mjpeg$%*" the last part is ignore making the string parse correctly. A single pair should end by either string terminator or pair terminator. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
f4632931d5
commit
3f6ac2bccf
@ -3563,10 +3563,14 @@ static const char* parse_next_video_codec(const char *codecs, char **encoder,
|
||||
}
|
||||
int n;
|
||||
*encoder = *codec = NULL;
|
||||
if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec, &n) != 2) {
|
||||
return codecs + strcspn(codecs, ";");
|
||||
if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec, &n) == 2) {
|
||||
// this avoids accepting "encoder:codec" followed by garbage like "$%*"
|
||||
if (codecs[n] != ';' && codecs[n] != '\0') {
|
||||
free(*codec);
|
||||
*codec = NULL;
|
||||
}
|
||||
}
|
||||
return codecs + n;
|
||||
return codecs + strcspn(codecs, ";");
|
||||
}
|
||||
|
||||
static void reds_set_video_codecs_from_string(RedsState *reds, const char *codecs)
|
||||
|
||||
@ -115,6 +115,12 @@ static void codecs_bad(void)
|
||||
G_LOG_LEVEL_WARNING,
|
||||
"*spice: invalid encoder:codec value*",
|
||||
TRUE,
|
||||
},{
|
||||
// invalid character in codec
|
||||
"spice:mjpeg&",
|
||||
G_LOG_LEVEL_WARNING,
|
||||
"*spice: invalid encoder:codec value*",
|
||||
TRUE,
|
||||
},
|
||||
#if !defined(HAVE_GSTREAMER_1_0) && !defined(HAVE_GSTREAMER_0_10)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user