]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
format-table: fix potential segfault
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 26 Apr 2026 17:04:38 +0000 (02:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 27 Apr 2026 02:11:35 +0000 (11:11 +0900)
In format-table.h, TABLE_IN_ADDR is commented as "Takes a union in_addr_union
(or a struct in_addr)". However, if we pass struct in_addr to table_add_many(),
the function reads more than the size of the struct.

src/shared/format-table.c

index 432e054d4a70cb034c13facdd99c052fa385ea31..f678a6722cec946c89df9f842eb0370742086cc2 100644 (file)
@@ -1081,12 +1081,12 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
                         break;
 
                 case TABLE_IN_ADDR:
-                        buffer.address = *va_arg(ap, union in_addr_union *);
+                        buffer.address.in = *va_arg(ap, struct in_addr *);
                         data = &buffer.address.in;
                         break;
 
                 case TABLE_IN6_ADDR:
-                        buffer.address = *va_arg(ap, union in_addr_union *);
+                        buffer.address.in6 = *va_arg(ap, struct in6_addr *);
                         data = &buffer.address.in6;
                         break;