[libc-commits] [libc] 1ef05d0 - [libc] Give struct sockaddr its full sa_data (#236518)

via libc-commits libc-commits at lists.llvm.org
Thu Oct 29 03:06:24 PDT 2026


Author: Mike Lothian
Date: 2026-10-29T11:06:18+01:00
New Revision: 1ef05d039f4853b19e28558617189d0e3749c598

URL: https://github.com/llvm/llvm-project/commit/1ef05d039f4853b19e28558617189d0e3749c598
DIFF: https://github.com/llvm/llvm-project/commit/1ef05d039f4853b19e28558617189d0e3749c598.diff

LOG: [libc] Give struct sockaddr its full sa_data (#236518)

sa_data was one byte, with a comment saying it stood in for a longer
array, which made sizeof(struct sockaddr) four rather than sixteen. Code
sizes address buffers against that: the kernel's sockaddr_vm computes
its padding by subtracting the known fields from sizeof(struct
sockaddr), which underflowed to an array of 2^64 elements

A real address is passed as one of the per-family structures, so the
array only has to fix the size. Fourteen bytes is the size the kernel
and every other libc give it

AI disclosure: this patch was written with Claude Code. I reviewed the
change. There is no test since this is a type definition

Assisted-by: Claude

Added: 
    

Modified: 
    libc/include/llvm-libc-types/struct_sockaddr.h

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-types/struct_sockaddr.h b/libc/include/llvm-libc-types/struct_sockaddr.h
index d85f0919259cd1..ebccbc08f14cd4 100644
--- a/libc/include/llvm-libc-types/struct_sockaddr.h
+++ b/libc/include/llvm-libc-types/struct_sockaddr.h
@@ -1,10 +1,15 @@
-//===-- Definition of struct sockaddr -------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of struct sockaddr.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_TYPES_STRUCT_SOCKADDR_H
 #define LLVM_LIBC_TYPES_STRUCT_SOCKADDR_H
@@ -13,9 +18,11 @@
 
 struct __attribute__((may_alias)) sockaddr {
   sa_family_t sa_family;
-  // sa_data is a variable length array. It is provided with a length of one
-  // here as a placeholder.
-  char sa_data[1];
+  // A real address is longer than this and is passed as one of the
+  // per-family structures instead. The length is what makes the whole
+  // structure sixteen bytes, which is the size the kernel's own generic
+  // address is and which code sizes its buffers against.
+  char sa_data[14];
 };
 
 #endif // LLVM_LIBC_TYPES_STRUCT_SOCKADDR_H


        


More information about the libc-commits mailing list