diff options
-rw-r--r-- | src/net_permissions.h | 6 | ||||
-rw-r--r-- | src/test/fuzz/net_permissions.cpp | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/net_permissions.h b/src/net_permissions.h index bba0ea1695..142b317bf6 100644 --- a/src/net_permissions.h +++ b/src/net_permissions.h @@ -51,8 +51,14 @@ public: { flags = static_cast<NetPermissionFlags>(flags | f); } + //! ClearFlag is only called with `f` == NetPermissionFlags::PF_ISIMPLICIT. + //! If that should change in the future, be aware that ClearFlag should not + //! be called with a subflag of a multiflag, e.g. NetPermissionFlags::PF_RELAY + //! or NetPermissionFlags::PF_DOWNLOAD, as that would leave `flags` in an + //! invalid state corresponding to none of the existing flags. static inline void ClearFlag(NetPermissionFlags& flags, NetPermissionFlags f) { + assert(f == NetPermissionFlags::PF_ISIMPLICIT); flags = static_cast<NetPermissionFlags>(flags & ~f); } }; diff --git a/src/test/fuzz/net_permissions.cpp b/src/test/fuzz/net_permissions.cpp index 544a33047b..6fdf4b653c 100644 --- a/src/test/fuzz/net_permissions.cpp +++ b/src/test/fuzz/net_permissions.cpp @@ -25,7 +25,7 @@ FUZZ_TARGET(net_permissions) (void)NetPermissions::ToStrings(net_whitebind_permissions.m_flags); (void)NetPermissions::AddFlag(net_whitebind_permissions.m_flags, net_permission_flags); assert(NetPermissions::HasFlag(net_whitebind_permissions.m_flags, net_permission_flags)); - (void)NetPermissions::ClearFlag(net_whitebind_permissions.m_flags, net_permission_flags); + (void)NetPermissions::ClearFlag(net_whitebind_permissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT); (void)NetPermissions::ToStrings(net_whitebind_permissions.m_flags); } @@ -35,7 +35,7 @@ FUZZ_TARGET(net_permissions) (void)NetPermissions::ToStrings(net_whitelist_permissions.m_flags); (void)NetPermissions::AddFlag(net_whitelist_permissions.m_flags, net_permission_flags); assert(NetPermissions::HasFlag(net_whitelist_permissions.m_flags, net_permission_flags)); - (void)NetPermissions::ClearFlag(net_whitelist_permissions.m_flags, net_permission_flags); + (void)NetPermissions::ClearFlag(net_whitelist_permissions.m_flags, NetPermissionFlags::PF_ISIMPLICIT); (void)NetPermissions::ToStrings(net_whitelist_permissions.m_flags); } } |