summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Dariz <luca@orpolo.org>2022-06-28 11:49:26 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-27 23:52:43 +0200
commit6aec25c58dd76ad4506ee7b5830ced92ab58ca0e (patch)
tree804f55ad8e7a1afd99f0ab104dca89a8506daf50
parentd29057d0866a663d4a5a867147a4a6366c12a647 (diff)
add check for whole message size
* user.c: ensure fixed-length messages have the correct size. In addition to the single-fields check, this also include padding. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628094927.442907-3-luca@orpolo.org>
-rw-r--r--user.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/user.c b/user.c
index 9aff07c..9a84fe4 100644
--- a/user.c
+++ b/user.c
@@ -275,7 +275,10 @@ WriteMsgSend(FILE *file, const routine_t *rt)
char SendSize[24];
if (rt->rtNumRequestVar == 0)
+ {
sprintf(SendSize, "%d", rt->rtRequestSize);
+ fprintf(file, "\t_Static_assert(sizeof(Request) == %s, \"Request expected to be %s bytes\");\n", SendSize, SendSize);
+ }
else
strcpy(SendSize, "msgh_size");
@@ -339,8 +342,10 @@ WriteMsgRPC(FILE *file, const routine_t *rt)
char SendSize[24];
if (rt->rtNumRequestVar == 0)
+ {
sprintf(SendSize, "%d", rt->rtRequestSize);
- else
+ fprintf(file, "\t_Static_assert(sizeof(Request) == %s, \"Request expected to be %s bytes\");\n", SendSize, SendSize);
+ } else
strcpy(SendSize, "msgh_size");
if (IsKernelUser)