rtmp: use bytes.Equal for signature matching

This commit is contained in:
Dan Kortschak 2018-09-06 12:26:35 +09:30
parent 6c6ed78e8f
commit aac0801cdb
1 changed files with 4 additions and 10 deletions

View File

@ -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
}