Skip to content

Commit

Permalink
fix security bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Oct 7, 2024
1 parent ca323e5 commit 9b2cb9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions files/lib/data/discord/bot/DiscordBot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use wcf\data\file\File;
use wcf\system\cache\builder\DiscordGuildChannelCacheBuilder;
use wcf\system\discord\DiscordApi;
use wcf\system\WCF;

/**
* Discord-Bot-Objekt
Expand Down Expand Up @@ -95,4 +96,17 @@ public function getWebhookAvatarData(): ?string

return 'data:' . $file->mimeType . ';base64,' . \base64_encode(\file_get_contents($file->getPathname()));
}

public static function findByFileID(int $fileID): ?DiscordBot
{
$sql = "
SELECT *
FROM wcf1_discord_bot
WHERE botID = ?
";
$stmnt = WCF::getDB()->prepare($sql);
$stmnt->execute([$fileID]);

return $stmnt->fetchObject(DiscordBot::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public function validateUpload(File $file): void
}
}

#[Override]
public function canAdopt(File $file, array $context): bool
{
return DiscordBot::findByFileID($file->fileID) === null;
}

#[Override]
public function adopt(File $file, array $context): void
{
Expand Down

0 comments on commit 9b2cb9f

Please sign in to comment.