diff options
author | Thomas Haller <thaller@redhat.com> | 2023-06-26 15:07:31 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-06-26 15:15:59 +0200 |
commit | 0505a1fc52695ed6e5221d0aae0807e64102d272 (patch) | |
tree | f8ddf06c8a753a24f3e5085719e735045b665c7a | |
parent | f727c233c49cd3c7f94e0c15108d508f762a0ece (diff) |
platform/trivial: add code comment to NMP_SYSCTL_PATHID_NETDIR_A()
-rw-r--r-- | src/libnm-platform/nm-platform.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 83247f2ec6..aeea5c42db 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -1534,6 +1534,12 @@ const char *nm_link_type_to_string(NMLinkType link_type); #define NMP_SYSCTL_PATHID_ABSOLUTE(path) ((const char *) NULL), -1, (path) +/* Uses alloca(). Use with care. + * + * Like NMP_SYSCTL_PATHID_NETDIR_A(), but "path" must not be a string literal. + * This is the "UNSAFE" part, where there is no compile time check for the + * maximum string length. It still must be reasonably short to not overflow + * the stack (the runtime assert checks for <200 chars). */ #define NMP_SYSCTL_PATHID_NETDIR_UNSAFE_A(dirfd, ifname, path) \ nm_sprintf_buf_unsafe_a(NM_STRLEN("net:/sys/class/net//\0") + NM_IFNAMSIZ + ({ \ const gsize _l = strlen(path); \ @@ -1546,6 +1552,7 @@ const char *nm_link_type_to_string(NMLinkType link_type); (path)), \ (dirfd), (path) +/* Uses alloca(). Use with care. */ #define NMP_SYSCTL_PATHID_NETDIR_A(dirfd, ifname, path) \ nm_sprintf_bufa(NM_STRLEN("net:/sys/class/net//" path "/\0") + NM_IFNAMSIZ, \ "net:/sys/class/net/%s/%s", \ |