[compiler-rt] [compiler-rt][sanitizer-common] intercept getaddrinfo_a for Linux. (PR #123167)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 23:00:51 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 1797fb6b233c548817008b9c39c6af06d12cae99 fbf4bf1aa6e1689f49ec92ae700a7e7745f17f82 --extensions inc,h -- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 94d1eb03b7..469fb6307e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -10264,40 +10264,47 @@ INTERCEPTOR(SSIZE_T, freadlink, int fd, char *buf, SIZE_T bufsiz) {
 #endif
 
 #if SANITIZER_INTERCEPT_GETADDRINFO_A
-INTERCEPTOR(int, getaddrinfo_a, int mode, struct __sanitizer_gaicb *list, int num,
-            void* sevp) {
+INTERCEPTOR(int, getaddrinfo_a, int mode, struct __sanitizer_gaicb *list,
+            int num, void *sevp) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, getaddrinfo_a, mode, list, num, sevp);
   if (sevp) {
     COMMON_INTERCEPTOR_READ_RANGE(ctx, sevp, struct_sigevent_sz);
   }
   if (list) {
-    for (int i = 0; i < num; i ++) {
+    for (int i = 0; i < num; i++) {
       struct __sanitizer_gaicb *cb = list[i];
       COMMON_INTERCEPTOR_READ_RANGE(ctx, cb, sizeof(__sanitizer_gaicb));
       if (cb->ar_name)
-        COMMON_INTERCEPTOR_READ_RANGE(ctx, cb->ar_name, internal_strlen(cb->ar_name) + 1);
+        COMMON_INTERCEPTOR_READ_RANGE(ctx, cb->ar_name,
+                                      internal_strlen(cb->ar_name) + 1);
       if (cb->ar_service)
-        COMMON_INTERCEPTOR_READ_RANGE(ctx, cb->ar_service, internal_strlen(cb->ar_service) + 1);
+        COMMON_INTERCEPTOR_READ_RANGE(ctx, cb->ar_service,
+                                      internal_strlen(cb->ar_service) + 1);
       if (cb->ar_request) {
-        COMMON_INTERCEPTOR_READ_RANGE(ctx, cb->ar_request, sizeof(__sanitizer_addrinfo));
+        COMMON_INTERCEPTOR_READ_RANGE(ctx, cb->ar_request,
+                                      sizeof(__sanitizer_addrinfo));
       }
     }
   }
 
   int res = REAL(getaddrinfo_a)(mode, list, num, sevp);
   if (res == 0 && list) {
-    for (int i = 0; i < num; i ++) {
+    for (int i = 0; i < num; i++) {
       struct __sanitizer_addrinfo *result = list[i]->ar_result;
       if (result) {
         while (result) {
-          COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result, sizeof(__sanitizer_addrinfo));
-	  if (result->ai_addr)
-            COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result->ai_addr, result->ai_addrlen);
-	  if (result->ai_canonname)
-            COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result->ai_canonname, internal_strlen(result->ai_canonname) + 1);
-	  result = result->ai_next;
-	}
+          COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result,
+                                         sizeof(__sanitizer_addrinfo));
+          if (result->ai_addr)
+            COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result->ai_addr,
+                                           result->ai_addrlen);
+          if (result->ai_canonname)
+            COMMON_INTERCEPTOR_WRITE_RANGE(
+                ctx, result->ai_canonname,
+                internal_strlen(result->ai_canonname) + 1);
+          result = result->ai_next;
+        }
       }
     }
   }
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 6c54d1f564..99f2aa4acf 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -788,14 +788,14 @@ struct __sanitizer_addrinfo {
   struct __sanitizer_addrinfo *ai_next;
 };
 
-#if SANITIZER_LINUX
+#  if SANITIZER_LINUX
 struct __sanitizer_gaicb {
   const char *ar_name;
   const char *ar_service;
   const struct __sanitizer_addrinfo ar_request;
   struct __sanitizer_addrinfo *ar_result;
 };
-#endif
+#  endif
 
 struct __sanitizer_hostent {
   char *h_name;

``````````

</details>


https://github.com/llvm/llvm-project/pull/123167


More information about the llvm-commits mailing list