From 9abcfb138ba13b7d18faeaf752632ba197cd6cd7 Mon Sep 17 00:00:00 2001 From: Saxon Date: Sun, 28 Apr 2019 12:27:54 +0930 Subject: [PATCH] protocol/rtsp: checking error from scans --- protocol/rtsp/rtsp.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/protocol/rtsp/rtsp.go b/protocol/rtsp/rtsp.go index 605057ff..eba7f20f 100644 --- a/protocol/rtsp/rtsp.go +++ b/protocol/rtsp/rtsp.go @@ -141,12 +141,18 @@ func ReadResponse(r io.Reader) (*Response, error) { } var proto string - fmt.Sscanf(s, "%s %d %s", &proto, &resp.StatusCode, &resp.Status) + _, err = fmt.Sscanf(s, "%s %d %s", &proto, &resp.StatusCode, &resp.Status) + if err != nil { + return nil, err + } s1 := strings.Split(proto, "/") resp.Proto = s1[0] - fmt.Sscanf(s1[1], "%d.%d", &resp.ProtoMajor, &resp.ProtoMinor) + _, err = fmt.Sscanf(s1[1], "%d.%d", &resp.ProtoMajor, &resp.ProtoMinor) + if err != nil { + return nil, err + } // Read headers. for {