mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Protect against empty ids.
This commit is contained in:
parent
c3a19c9128
commit
0261558e07
1 changed files with 26 additions and 8 deletions
|
@ -790,6 +790,8 @@ type kickAction struct {
|
||||||
message string
|
message string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errEmptyId = group.ProtocolError("empty id")
|
||||||
|
|
||||||
func clientLoop(c *webClient, ws *websocket.Conn) error {
|
func clientLoop(c *webClient, ws *websocket.Conn) error {
|
||||||
read := make(chan interface{}, 1)
|
read := make(chan interface{}, 1)
|
||||||
go clientReader(ws, read, c.done)
|
go clientReader(ws, read, c.done)
|
||||||
|
@ -1038,14 +1040,12 @@ func closeDownConn(c *webClient, id string, message string) error {
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
log.Printf("Close down connection: %v", err)
|
log.Printf("Close down connection: %v", err)
|
||||||
}
|
}
|
||||||
if id != "" {
|
err = c.write(clientMessage{
|
||||||
err := c.write(clientMessage{
|
Type: "close",
|
||||||
Type: "close",
|
Id: id,
|
||||||
Id: id,
|
})
|
||||||
})
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if message != "" {
|
if message != "" {
|
||||||
err := c.error(group.UserError(message))
|
err := c.error(group.UserError(message))
|
||||||
|
@ -1210,6 +1210,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
case "request":
|
case "request":
|
||||||
return c.setRequested(m.Request)
|
return c.setRequested(m.Request)
|
||||||
case "offer":
|
case "offer":
|
||||||
|
if m.Id == "" {
|
||||||
|
return errEmptyId
|
||||||
|
}
|
||||||
if !c.permissions.Present {
|
if !c.permissions.Present {
|
||||||
if m.Replace != "" {
|
if m.Replace != "" {
|
||||||
delUpConn(c, m.Replace, c.id, true)
|
delUpConn(c, m.Replace, c.id, true)
|
||||||
|
@ -1226,6 +1229,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
return failUpConnection(c, m.Id, "negotiation failed")
|
return failUpConnection(c, m.Id, "negotiation failed")
|
||||||
}
|
}
|
||||||
case "answer":
|
case "answer":
|
||||||
|
if m.Id == "" {
|
||||||
|
return errEmptyId
|
||||||
|
}
|
||||||
err := gotAnswer(c, m.Id, m.SDP)
|
err := gotAnswer(c, m.Id, m.SDP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("gotAnswer: %v", err)
|
log.Printf("gotAnswer: %v", err)
|
||||||
|
@ -1249,6 +1255,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "renegotiate":
|
case "renegotiate":
|
||||||
|
if m.Id == "" {
|
||||||
|
return errEmptyId
|
||||||
|
}
|
||||||
down := getDownConn(c, m.Id)
|
down := getDownConn(c, m.Id)
|
||||||
if down != nil {
|
if down != nil {
|
||||||
err := negotiate(c, down, true, "")
|
err := negotiate(c, down, true, "")
|
||||||
|
@ -1261,6 +1270,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
log.Printf("Trying to renegotiate unknown connection")
|
log.Printf("Trying to renegotiate unknown connection")
|
||||||
}
|
}
|
||||||
case "close":
|
case "close":
|
||||||
|
if m.Id == "" {
|
||||||
|
return errEmptyId
|
||||||
|
}
|
||||||
err := delUpConn(c, m.Id, c.id, true)
|
err := delUpConn(c, m.Id, c.id, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Deleting up connection %v: %v",
|
log.Printf("Deleting up connection %v: %v",
|
||||||
|
@ -1268,8 +1280,14 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case "abort":
|
case "abort":
|
||||||
|
if m.Id == "" {
|
||||||
|
return errEmptyId
|
||||||
|
}
|
||||||
return closeDownConn(c, m.Id, "")
|
return closeDownConn(c, m.Id, "")
|
||||||
case "ice":
|
case "ice":
|
||||||
|
if m.Id == "" {
|
||||||
|
return errEmptyId
|
||||||
|
}
|
||||||
if m.Candidate == nil {
|
if m.Candidate == nil {
|
||||||
return group.ProtocolError("null candidate")
|
return group.ProtocolError("null candidate")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue