mirror of https://bitbucket.org/ausocean/av.git
rtmp: use bytes.Equal for signature matching
This commit is contained in:
parent
6c6ed78e8f
commit
aac0801cdb
14
rtmp/rtmp.go
14
rtmp/rtmp.go
|
@ -46,6 +46,7 @@ typedef struct sockaddr sockaddr;
|
|||
import "C"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
@ -1586,7 +1587,6 @@ func C_RTMP_ReadPacket(r *C_RTMP, packet *C_RTMPPacket) (ok bool) {
|
|||
// int HandShake(RTMP* r, int FP9HandShake);
|
||||
// rtmp.c +3744
|
||||
func C_HandShake(r *C_RTMP, FP9HandShake int32) (ok bool) {
|
||||
var bMatch int
|
||||
var uptime, suptime uint32
|
||||
var typ byte
|
||||
//clientbuf := make([]byte, RTMP_SIG_SIZE+1)
|
||||
|
@ -1642,15 +1642,9 @@ func C_HandShake(r *C_RTMP, FP9HandShake int32) (ok bool) {
|
|||
return false
|
||||
}
|
||||
|
||||
// TODO: find golang memcmp
|
||||
bMatch = 0
|
||||
if memcmp(unsafe.Pointer(&serversig[0]), unsafe.Pointer(clientsig),
|
||||
RTMP_SIG_SIZE) == 0 {
|
||||
bMatch = 1
|
||||
}
|
||||
|
||||
if bMatch == 0 {
|
||||
log.Println("Client signature does not match!")
|
||||
if !bytes.Equal(serversig[:RTMP_SIG_SIZE], clientbuf[1:RTMP_SIG_SIZE+1]) {
|
||||
log.Printf("Client signature does not match: %q != %q",
|
||||
serversig[:RTMP_SIG_SIZE], clientbuf[1:RTMP_SIG_SIZE+1])
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue