summaryrefslogtreecommitdiff
path: root/src/test/test-sizeof.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-21 08:45:19 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-29 10:20:42 +0200
commit0985c7c4e22c8dbbea4398cf3453da45ebf63800 (patch)
treebbb08300ff3c022617628b8cbff223218b2ebc62 /src/test/test-sizeof.c
parentb12ef7141648be40fd8c4b0209a742f2151736d9 (diff)
downloadsystemd-0985c7c4e22c8dbbea4398cf3453da45ebf63800.tar.gz
Rework cpu affinity parsing
The CPU_SET_S api is pretty bad. In particular, it has a parameter for the size of the array, but operations which take two (CPU_EQUAL_S) or even three arrays (CPU_{AND,OR,XOR}_S) still take just one size. This means that all arrays must be of the same size, or buffer overruns will occur. This is exactly what our code would do, if it received an array of unexpected size over the network. ("Unexpected" here means anything different from what cpu_set_malloc() detects as the "right" size.) Let's rework this, and store the size in bytes of the allocated storage area. The code will now parse any number up to 8191, independently of what the current kernel supports. This matches the kernel maximum setting for any architecture, to make things more portable. Fixes #12605.
Diffstat (limited to 'src/test/test-sizeof.c')
-rw-r--r--src/test/test-sizeof.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c
index 35b087653e..7fc16a62b6 100644
--- a/src/test/test-sizeof.c
+++ b/src/test/test-sizeof.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <sched.h>
#include <stdio.h>
#include <string.h>
@@ -65,6 +66,8 @@ int main(void) {
info(uid_t);
info(gid_t);
+ info(__cpu_mask);
+
info(enum Enum);
info(enum BigEnum);
info(enum BigEnum2);