chore: some fuzz fixes
This commit is contained in:
1 parent
6e94e6dfca
commit
a2b92e6dc5
36 files changed
+1466
-2814
No files matched your search
@@ -2,25 +2,40 @@
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use pumpkin_protocol::ServerPacket;
|
||||
use pumpkin_protocol::java::{
|
||||
client::{
|
||||
config::CFinishConfig,
|
||||
login::CLoginDisconnect,
|
||||
play::CPlayerPosition,
|
||||
status::{CPingResponse, CStatusResponse},
|
||||
},
|
||||
packet_decoder::TCPNetworkDecoder,
|
||||
server::{
|
||||
config::{
|
||||
SClientInformationConfig, SConfigCookieResponse, SConfigResourcePack, SKnownPacks,
|
||||
SPluginMessage,
|
||||
SAcknowledgeFinishConfig, SClientInformationConfig, SConfigCookieResponse,
|
||||
SConfigResourcePack, SCustomClickAction as SConfigCustomClickAction,
|
||||
SKeepAlive as SConfigKeepAlive, SKnownPacks, SPluginMessage,
|
||||
},
|
||||
handshake::SHandShake,
|
||||
login::{SEncryptionResponse, SLoginCookieResponse, SLoginPluginResponse, SLoginStart},
|
||||
login::{
|
||||
SEncryptionResponse, SLoginAcknowledged, SLoginCookieResponse, SLoginPluginResponse,
|
||||
SLoginStart,
|
||||
},
|
||||
play::{
|
||||
SChangeGameMode, SChatCommand, SChatMessage, SChunkBatch, SClickSlot, SClientCommand,
|
||||
SClientInformationPlay, SCloseContainer, SCommandSuggestion, SConfirmTeleport,
|
||||
SContainerButtonClick, SCookieResponse, SCustomPayload, SInteract, SKeepAlive,
|
||||
SMoveVehicle, SPaddleBoat, SPickItemFromBlock, SPlayPingRequest, SPlayerAbilities,
|
||||
SPlayerAction, SPlayerCommand, SPlayerInput, SPlayerLoaded, SPlayerPosition,
|
||||
SPlayerPositionRotation, SPlayerRotation, SPlayerSession, SSetCommandBlock,
|
||||
SSetCreativeSlot, SSetHeldItem, SSetPlayerGround, SSwingArm, SUpdateSign, SUseItem,
|
||||
SAttack, SBundleItemSelected, SChangeGameMode, SChatCommand, SChatMessage, SChunkBatch,
|
||||
SClickSlot, SClientCommand, SClientInformationPlay, SClientTickEnd, SCloseContainer,
|
||||
SCommandSuggestion, SConfirmTeleport, SContainerButtonClick, SCookieResponse,
|
||||
SCustomClickAction as SPlayCustomClickAction, SCustomPayload, SDebugSampleSubscription,
|
||||
SDebugSubscriptionRequest, SEditBook, SInteract, SJigsawGenerate,
|
||||
SKeepAlive as SPlayKeepAlive, SMoveVehicle, SPaddleBoat, SPickItemFromBlock,
|
||||
SPickItemFromEntity, SPlaceRecipe, SPlayPingRequest, SPlayerAbilities, SPlayerAction,
|
||||
SPlayerCommand, SPlayerInput, SPlayerLoaded, SPlayerPosition, SPlayerPositionRotation,
|
||||
SPlayerRotation, SPlayerSession, SRecipeBookChangeSettings, SRecipeBookSeenRecipe,
|
||||
SRenameItem, SSeenAdvancement, SSelectTrade, SSetBeacon, SSetCommandBlock,
|
||||
SSetCreativeSlot, SSetHeldItem, SSetJigsawBlock, SSetPlayerGround, SSetTestBlock,
|
||||
SSwingArm, STeleportToEntity, STestInstanceBlockAction, SUpdateSign, SUseItem,
|
||||
SUseItemOn,
|
||||
},
|
||||
status::SStatusPingRequest,
|
||||
status::{SStatusPingRequest, SStatusRequest},
|
||||
},
|
||||
};
|
||||
use pumpkin_util::version::JavaMinecraftVersion;
|
||||
@@ -31,16 +46,14 @@ const TARGET_VERSION: JavaMinecraftVersion = JavaMinecraftVersion::V_26_1;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helper: run every known ServerPacket::read against the same payload.
|
||||
// Uses a Cursor and the Version enum as required by the new signature.
|
||||
// Uses a slice and the Version enum as required by the ServerPacket signature.
|
||||
// ---------------------------------------------------------------------------
|
||||
fn fuzz_all_deserializers(payload: &[u8]) {
|
||||
let mut cursor = Cursor::new(payload);
|
||||
|
||||
macro_rules! run_read {
|
||||
($($packet:ty),* $(,)?) => {
|
||||
$(
|
||||
cursor.set_position(0);
|
||||
let _ = <$packet>::read(&mut cursor, &TARGET_VERSION);
|
||||
let mut slice = payload;
|
||||
let _ = <$packet>::read(&mut slice, &TARGET_VERSION);
|
||||
)*
|
||||
};
|
||||
}
|
||||
@@ -50,54 +63,85 @@ fn fuzz_all_deserializers(payload: &[u8]) {
|
||||
SHandShake,
|
||||
// Status
|
||||
SStatusPingRequest,
|
||||
SStatusRequest,
|
||||
// Login
|
||||
SLoginStart,
|
||||
SEncryptionResponse,
|
||||
SLoginPluginResponse,
|
||||
SLoginCookieResponse,
|
||||
SLoginAcknowledged,
|
||||
// Config
|
||||
SAcknowledgeFinishConfig,
|
||||
SClientInformationConfig,
|
||||
SPluginMessage,
|
||||
SKnownPacks,
|
||||
SConfigCookieResponse,
|
||||
SConfigCustomClickAction,
|
||||
SConfigKeepAlive,
|
||||
SKnownPacks,
|
||||
SPluginMessage,
|
||||
SConfigResourcePack,
|
||||
// Play
|
||||
SConfirmTeleport,
|
||||
SAttack,
|
||||
SBundleItemSelected,
|
||||
SChangeGameMode,
|
||||
SChatCommand,
|
||||
SChatMessage,
|
||||
SClientInformationPlay,
|
||||
SChunkBatch,
|
||||
SClickSlot,
|
||||
SClientCommand,
|
||||
SPlayerInput,
|
||||
SClientInformationPlay,
|
||||
SClientTickEnd,
|
||||
SCloseContainer,
|
||||
SCommandSuggestion,
|
||||
SConfirmTeleport,
|
||||
SContainerButtonClick,
|
||||
SCookieResponse,
|
||||
SPlayCustomClickAction,
|
||||
SCustomPayload,
|
||||
SDebugSampleSubscription,
|
||||
SDebugSubscriptionRequest,
|
||||
SEditBook,
|
||||
SInteract,
|
||||
SJigsawGenerate,
|
||||
SPlayKeepAlive,
|
||||
SMoveVehicle,
|
||||
SPaddleBoat,
|
||||
SInteract,
|
||||
SKeepAlive,
|
||||
SPickItemFromBlock,
|
||||
SPickItemFromEntity,
|
||||
SPlayPingRequest,
|
||||
SPlaceRecipe,
|
||||
SPlayerAbilities,
|
||||
SPlayerAction,
|
||||
SPlayerCommand,
|
||||
SPlayerInput,
|
||||
SPlayerLoaded,
|
||||
SPlayerPosition,
|
||||
SPlayerPositionRotation,
|
||||
SPlayerRotation,
|
||||
SSetPlayerGround,
|
||||
SPickItemFromBlock,
|
||||
SPlayerAbilities,
|
||||
SPlayerAction,
|
||||
SSetCommandBlock,
|
||||
SPlayerCommand,
|
||||
SPlayerLoaded,
|
||||
SPlayPingRequest,
|
||||
SClickSlot,
|
||||
SContainerButtonClick,
|
||||
SSetHeldItem,
|
||||
SSetCreativeSlot,
|
||||
SSwingArm,
|
||||
SUpdateSign,
|
||||
SUseItemOn,
|
||||
SUseItem,
|
||||
SCommandSuggestion,
|
||||
SCookieResponse,
|
||||
SCloseContainer,
|
||||
SChunkBatch,
|
||||
SPlayerSession,
|
||||
SCustomPayload,
|
||||
SRecipeBookChangeSettings,
|
||||
SRecipeBookSeenRecipe,
|
||||
SRenameItem,
|
||||
SSeenAdvancement,
|
||||
SSelectTrade,
|
||||
SSetBeacon,
|
||||
SSetCommandBlock,
|
||||
SSetCreativeSlot,
|
||||
SSetHeldItem,
|
||||
SSetJigsawBlock,
|
||||
SSetPlayerGround,
|
||||
SSetTestBlock,
|
||||
SSwingArm,
|
||||
STeleportToEntity,
|
||||
STestInstanceBlockAction,
|
||||
SUpdateSign,
|
||||
SUseItem,
|
||||
SUseItemOn,
|
||||
// Clientbound packets implementing ServerPacket
|
||||
CFinishConfig,
|
||||
CLoginDisconnect,
|
||||
CPlayerPosition,
|
||||
CPingResponse,
|
||||
CStatusResponse,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -131,13 +175,13 @@ fuzz_target!(|data: &[u8]| {
|
||||
2 => {
|
||||
let mut aes_key = [0u8; 16];
|
||||
aes_key.copy_from_slice(key);
|
||||
decoder.set_encryption(&aes_key);
|
||||
let _ = decoder.set_encryption(&aes_key);
|
||||
}
|
||||
3 => {
|
||||
decoder.set_compression(256);
|
||||
let mut aes_key = [0u8; 16];
|
||||
aes_key.copy_from_slice(key);
|
||||
decoder.set_encryption(&aes_key);
|
||||
let _ = decoder.set_encryption(&aes_key);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user