Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
fix recieiving attachment
Browse files Browse the repository at this point in the history
leak less infomations
  • Loading branch information
[email protected] committed Nov 20, 2021
1 parent 6d2d3f6 commit 499de57
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/textsecure/crayfish
6 changes: 4 additions & 2 deletions crayfish/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (c *CrayfishInstance) StartWebsocket() error {
}
return err
}
log.Debugln("[textsecure-crayfish-ws] incoming msg", string(bmsg))
log.Debugln("[textsecure-crayfish-ws] incoming msg")
csm := &CrayfishWebSocketMessage{}
err = json.Unmarshal(bmsg, csm)
if err != nil {
Expand Down Expand Up @@ -549,7 +549,7 @@ func (c *CrayfishInstance) HandleEnvelope(msg []byte) (*CrayfishWebSocketRespons
envelopeMessage := &CrayfishWebSocketRequest_HANDLE_ENVELOPE_MESSAGE{
Message: sEnc,
}
log.Debugln("[textsecure-crayfish-ws] Sending envelope", msg)
log.Debugln("[textsecure-crayfish-ws] Sending envelope")

request := &CrayfishWebSocketRequestMessage{
Type: &requestType,
Expand All @@ -567,6 +567,7 @@ func (c *CrayfishInstance) HandleEnvelope(msg []byte) (*CrayfishWebSocketRespons
c.wsconn.send <- m
c.receiveChannel = make(chan *CrayfishWebSocketResponseMessage, 1)
response := <-c.receiveChannel
log.Debugf("[textsecure-crayfish-ws] HandleEnvelope recieved an response")
rm, err := json.Marshal(response.Message)
if err != nil {
return nil, err
Expand All @@ -576,5 +577,6 @@ func (c *CrayfishInstance) HandleEnvelope(msg []byte) (*CrayfishWebSocketRespons
if err != nil {
return nil, err
}

return &data, nil
}
3 changes: 2 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (
)

func handleMessage(srcE164 string, srcUUID string, timestamp uint64, b []byte) error {
b = stripPadding(b)

content := &signalservice.Content{}
err := proto.Unmarshal(b, content)
if err != nil {
log.Errorln("[textsecure] handleMessage umarshalling", err)
return err
}
log.Debugln("[textsecure] handleMessage")

if dm := content.GetDataMessage(); dm != nil {
return handleDataMessage(srcE164, srcUUID, timestamp, dm)
Expand Down
2 changes: 2 additions & 0 deletions textsecure.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ func handleReceivedMessage(env *signalservice.Envelope) error {
if err != nil {
return err
}
b = stripPadding(b)
err = handleMessage(env.GetSourceE164(), env.GetSourceUuid(), env.GetTimestamp(), b)
if err != nil {
return err
Expand Down Expand Up @@ -650,6 +651,7 @@ func handleReceivedMessage(env *signalservice.Envelope) error {
if err != nil {
return err
}
b = stripPadding(b)
err = handleMessage(env.GetSourceE164(), env.GetSourceUuid(), env.GetTimestamp(), b)
if err != nil {
return err
Expand Down

0 comments on commit 499de57

Please sign in to comment.