Skip to content

Commit 82bff3f

Browse files
committed
Limit DeviceToken length
1 parent c4ed50f commit 82bff3f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

route_register.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func doRegister(c *fiber.Ctx, compat bool) error {
5050
}
5151
}
5252

53+
// DeviceToken length is variable, but should not be too long.
54+
if len(deviceInfo.DeviceToken) > 128 {
55+
return c.Status(400).JSON(failed(400, "device token is invalid"))
56+
}
57+
5358
// if deviceInfo.DeviceKey=="", newKey will be filled with a new uuid
5459
// otherwise it equal to deviceInfo.DeviceKey
5560
newKey, err := db.SaveDeviceTokenByKey(deviceInfo.DeviceKey, deviceInfo.DeviceToken)

0 commit comments

Comments
 (0)