From 66bc6bbe33d091b20b7e4ad3b8cef4d1b98103b8 Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 29 Apr 2019 13:08:05 +0930 Subject: [PATCH] protocol/rtsp: only giving Sscanf s[5:] and then checking number of decimals read as well as error --- protocol/rtsp/rtsp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/rtsp/rtsp.go b/protocol/rtsp/rtsp.go index 501ae5be..22d84236 100644 --- a/protocol/rtsp/rtsp.go +++ b/protocol/rtsp/rtsp.go @@ -137,9 +137,9 @@ func ReadResponse(r io.Reader) (*Response, error) { } resp.Proto = "RTSP" - _, err = fmt.Sscanf(s[5:12], "%d.%d %d", &resp.ProtoMajor, &resp.ProtoMinor, &resp.StatusCode) - if err != nil { - return nil, err + n, err := fmt.Sscanf(s[5:], "%d.%d %d", &resp.ProtoMajor, &resp.ProtoMinor, &resp.StatusCode) + if err != nil || n != 3 { + return nil, fmt.Errorf("could not Sscanf response, error: %v", err) } // Read headers.