Add "expected size" parameter to getsysinfo()

This patch provides basic protection against damage resulting from
differently compiled servers blindly copying tables to one another.
In every getsysinfo() call, the caller is provided with the expected
size of the requested data structure. The callee fails the call if
the expected size does not match the data structure's actual size.
This commit is contained in:
David van Moolenbroek
2011-12-11 22:30:35 +01:00
parent 9701e9dfd2
commit 6f374faca5
17 changed files with 118 additions and 80 deletions

View File

@@ -3,14 +3,17 @@
#include <minix/sysinfo.h>
#include <minix/com.h>
PUBLIC int getsysinfo(who, what, where)
endpoint_t who; /* from whom to request info */
int what; /* what information is requested */
void *where; /* where to put it */
PUBLIC int getsysinfo(
endpoint_t who, /* from whom to request info */
int what, /* what information is requested */
void *where, /* where to put it */
size_t size /* how big it should be */
)
{
message m;
m.SI_WHAT = what;
m.SI_WHERE = where;
m.SI_SIZE = size;
if (_syscall(who, COMMON_GETSYSINFO, &m) < 0) return(-1);
return(0);
}