================
@@ -339,6 +344,49 @@ void call_recv_runtime(int fd, int n) {
   recvfrom(fd, buf, n, 0, (struct sockaddr *)0, 0);
 }
 
+void call_send(int fd) {
+  char buf[10];
+  send(fd, buf, 0, 0);
+  send(fd, buf, 10, 0);
+  send(fd, buf, 11, 0); // expected-warning {{'send' will always read past the 
end of the source buffer; source buffer has size 10, but the size is 11}}
+  send(fd, buf, -1, 0); // expected-warning {{'send' will always read past the 
end of the source buffer; source buffer has size 10, but the size is 
18446744073709551615}}
+}
+
+void call_sendto(int fd) {
+  char buf[10];
+  sendto(fd, buf, 0, 0, (const struct sockaddr *)0, 0);
+  sendto(fd, buf, 10, 0, (const struct sockaddr *)0, 0);
+  sendto(fd, buf, 11, 0, (const struct sockaddr *)0, 0); // expected-warning 
{{'sendto' will always read past the end of the source buffer; source buffer 
has size 10, but the size is 11}}
+  sendto(fd, buf, -1, 0, (const struct sockaddr *)0, 0); // expected-warning 
{{'sendto' will always read past the end of the source buffer; source buffer 
has size 10, but the size is 18446744073709551615}}
+}
+
+void call_send_subobject(int fd) {
+  struct {
+    char first[10];
+    char second[20];
+  } s;
+  send(fd, s.first, 35, 0); // expected-warning {{'send' will always read past 
the end of the source buffer; source buffer has size 30, but the size is 35}}
+}
+
+void call_send_runtime(int fd, int n) {
+  char buf[10];
+  send(fd, buf, n, 0);
+  sendto(fd, buf, n, 0, (const struct sockaddr *)0, 0);
+}
+
+#if !defined(__cplusplus) && !defined(USE_BUILTINS)
+typedef union {
+  const struct sockaddr *__sockaddr__;
+} __CONST_SOCKADDR_ARG __attribute__((__transparent_union__));
+ssize_t sendto(int, const void *, size_t, int, __CONST_SOCKADDR_ARG, 
socklen_t);
----------------
venk-ks wrote:

Done in f8fb369b8146: moved the  typedef to the top of  (under  in the  block) 
so  is declared once without redeclaration.

https://github.com/llvm/llvm-project/pull/228194
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to