bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] add check for whole message size


From: Luca Dariz
Subject: [PATCH 2/3] add check for whole message size
Date: Tue, 28 Jun 2022 11:49:26 +0200

* 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>
---
 user.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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)
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]