When you see something like this: /* args points to a PAGE_SIZE buffer, AppArmor requires that * the buffer must be null terminated or have size you just have to expect exploits. This is a problem that comes up repeatedly in the Linux kernel. When some kernel call accepts or returns variable-length data, the details are handled locally, not in some general-purpose functions for moving variable-sized data in and out o…
Nitpick: it's an internal kernel function being called by another kernel function, not a user-kernel interface. What you seem to want is a general-purpose string implementation for shuffling data around. With a safe append() preferably.
Yes. That's why we have collections in most languages now.