Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions server/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ func sendPushNotification(notification *Notification, uuids []string) error {
VAPIDPublicKey: config.vapidKeys.public,
VAPIDPrivateKey: config.vapidKeys.private,
TTL: 30, // seconds,
HTTPClient: &http.Client{
Timeout: 10 * time.Second,
},
})
if err != nil {
log.Printf("error sending notifications: %s", err)
Expand All @@ -196,11 +199,11 @@ func sendPushNotification(notification *Notification, uuids []string) error {
return errors.Join(failures...)
}

func getPlaceholders(values ...string) (placeholders string, parameters []interface{}) {
func getPlaceholders(values ...string) (placeholders string, parameters []any) {
n := len(values)
p := make([]string, n)
parameters = make([]interface{}, n)
for i := 0; i < n; i++ {
parameters = make([]any, n)
for i := range n {
p[i] = "?"
parameters[i] = values[i]
}
Expand Down
2 changes: 1 addition & 1 deletion server/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *Security) VerifySignature(clientKey uint32, msg []byte) bool {
}

func (s *Security) VerifyCounter(counter *uint32, msg []byte) bool {
if cnt := binary.BigEndian.Uint32(msg[4 : len(msg)-4]); *counter < cnt {
if cnt := binary.BigEndian.Uint32(msg[4:]); *counter < cnt {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already guaranteed by processMsgs to be at least 8 bytes long, but limiting it to len(msg)-4 may give a slice shorter than 4 bytes and cause Uint32 to panic

*counter = cnt
return true
}
Expand Down