]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
namespace-util: explicitly specify namespace_info[]'s size
authorMike Yuan <me@yhndnzj.com>
Mon, 22 Jul 2024 18:02:03 +0000 (20:02 +0200)
committerMike Yuan <me@yhndnzj.com>
Tue, 23 Jul 2024 17:30:54 +0000 (19:30 +0200)
We do this already in all string lookup tables. This way
it's guaranteed that iterators which ends with _NAMESPACE_TYPE_MAX
wouldn't overrun the array.

src/basic/namespace-util.c

index 5b4e43f9210ef90f488950a61edd71611fb34419..739867672e25855b245f227d8812765435ab50fe 100644 (file)
@@ -17,7 +17,7 @@
 #include "stdio-util.h"
 #include "user-util.h"
 
-const struct namespace_info namespace_info[] = {
+const struct namespace_info namespace_info[_NAMESPACE_TYPE_MAX + 1] = {
         [NAMESPACE_CGROUP] =  { "cgroup", "ns/cgroup", CLONE_NEWCGROUP,                          },
         [NAMESPACE_IPC]    =  { "ipc",    "ns/ipc",    CLONE_NEWIPC,                             },
         [NAMESPACE_NET]    =  { "net",    "ns/net",    CLONE_NEWNET,                             },