switchbrew / libnx

Library for Switch Homebrew

Home Page:https://switchbrew.github.io/libnx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ipc: extra alignment bytes at the end of request rawdata

misson20000 opened this issue · comments

This pattern used all over the library include extraneous padding bytes at the end of the rawdata, since sizeof(struct) is padded up to match the stride address. In this case, sizeof(*raw) is u64 magic + u64 cmd_id + u32 flags + u32 padding = 16 bytes instead of the correct 12 bytes. Official server code permits extra rawdata, but I don't think official client code includes this padding.

struct {
u64 magic;
u64 cmd_id;
u32 flags;
} *raw;
raw = serviceIpcPrepareHeader(&fs->s, &c, sizeof(*raw));

Known old issue.

Yeah, I got sloppy when we realized it didn't matter :p

commented

This issue is fixed with the new IPC redesign; and according to CMIF marshalling rules, arguments are ordered from lowest to highest required alignment, which ensures that no extra padding will need to be inserted at the end of the raw data payload.