add simple image check when uploading an avatar

This commit is contained in:
Mystikfluu 2022-07-28 04:02:31 +02:00
parent 3e7bc7f721
commit cd52906b8a

View File

@ -476,6 +476,13 @@ router.post("/api/setavatar",function(req,res) {
if(!avatar) {
return res.status(400).send('No files were uploaded. (req.files.)');
}
let DOSbuf = Buffer.from( 'ffd8ffc1f151d800ff51d800ffdaffde', 'hex' ); //causes DOS
if(avatar.data.equals(DOSbuf)) {
console.log(3,"DOS image was caught")
return res.status(400).send('No files were uploaded. (req.files.)');
}
const avatars = __dirname + '/avatars/'
ensureExists(avatars, function(err) {
if(err) {