Skip to contentSkip to conversation

fix one out-of-bounds access

PATCH New Norbert Lange 1 participant 2 messages Apr 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix one out-of-bounds access

---
 testsuite/smokey/net_common/smokey_net_server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testsuite/smokey/net_common/smokey_net_server.c +1 -1
index a0ed52fd9..2e19208e7 100644
@@ -89,7 +89,7 @@ rtnet_rtcfg_add_client(int fd, const char *hwaddr, const char *ipaddr)
 	cmd.args.add.ip_addr = ip.s_addr;
 	cmd.args.add.timeout = 3000;
 	memcpy(cmd.args.add.mac_addr, mac.ether_addr_octet,
-		sizeof(cmd.args.add.mac_addr));
+		sizeof(mac.ether_addr_octet));
 
 	check_unix(ioctl(fd, RTCFG_IOC_ADD, &cmd));
 }
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 add missing headers and casts, prefer POSIX definitions

see http://man7.org/linux/man-pages/man2/bind.2.html
and http://man7.org/linux/man-pages/man2/open.2.html
and http://man7.org/linux/man-pages/man7/sigevent.7.html

---
 demo/posix/cobalt/gpiopwm.c                  | 4 ++--
 testsuite/smokey/posix-select/posix-select.c | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)
demo/posix/cobalt/gpiopwm.c +2 -2
index b34cbf1e1..eddd5cce5 100644
@@ -219,7 +219,7 @@ static void *gpiopwm_udp_ctrl_thread(void *cookie)
 	saddr.sin_port = htons(port);
 	saddr.sin_family = AF_INET;
 
-	if (bind(sockfd, &saddr, sizeof(saddr)) < 0)
+	if (bind(sockfd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0)
 		perror("bind");
 
 	clen = sizeof(caddr);
@@ -230,7 +230,7 @@ static void *gpiopwm_udp_ctrl_thread(void *cookie)
 		print_config("UDP Server\n");
 
 		memset(buf,'\0', blen);
-		ret = recvfrom(sockfd, buf, blen - 1, 0, &caddr, &clen);
+		ret = recvfrom(sockfd, buf, blen - 1, 0, (struct sockaddr *)&caddr, &clen);
 		if (ret < 0)
 			perror("recvfrom");
 
testsuite/smokey/posix-select/posix-select.c +3 -0
index 6bd88ddb5..e9bf938b3 100644
@@ -30,6 +30,9 @@
 #include <pthread.h>
 #include <boilerplate/atomic.h>
 #include <sys/select.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <smokey/smokey.h>
 
 smokey_test_plugin(posix_select,
Signature · 1 line
2.17.0