This repository has been archived on 2026-01-16. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
amtu/amtu-1.0.4-cleanup.patch
2007-01-09 23:20:44 +00:00

76 lines
2.5 KiB
Diff

diff -urp amtu-1.0.4.orig/src/iodisktest.c amtu-1.0.4/src/iodisktest.c
--- amtu-1.0.4.orig/src/iodisktest.c 2007-01-09 15:41:48.000000000 -0500
+++ amtu-1.0.4/src/iodisktest.c 2007-01-09 16:32:38.000000000 -0500
@@ -74,6 +74,7 @@
#define MAXLINE 500
#define MAXINDEX 100
#define MAXMEMSIZE 10485670
+#define BDEVNAME_SIZE 32
// Structure to track info about partitions
typedef struct {
@@ -279,7 +280,7 @@ int iodisktest(int argc, char *argv[])
FILE *fname;
FILE *fs;
FILE *fs1;
- char token[10];
+ char token[BDEVNAME_SIZE];
char line[MAXLINE];
int num = 32;
int num_of_rands = 0;
diff -urp amtu-1.0.4.orig/src/networkio.c amtu-1.0.4/src/networkio.c
--- amtu-1.0.4.orig/src/networkio.c 2007-01-09 15:41:48.000000000 -0500
+++ amtu-1.0.4/src/networkio.c 2007-01-09 17:26:28.000000000 -0500
@@ -208,6 +208,10 @@ int get_interfaces()
ifr = ifc.ifc_req;
numifs = ifc.ifc_len/sizeof (struct ifreq);
+ if (numifs > MAX_INTERFACES) {
+ printf("Too many interfaces, only testing the first %d\n", MAX_INTERFACES);
+ numifs = MAX_INTERFACES;
+ }
if (debug)
printf("SIOCGIFCONF has %d interfaces in list:\n", numifs);
@@ -231,6 +235,7 @@ int get_interfaces()
memset(&ifr_sub, '\0', sizeof(struct ifreq));
strncpy(ifr_sub.ifr_name, ifr->ifr_name,
sizeof(ifr_sub.ifr_name));
+ ifr_sub.ifr_name[sizeof(ifr_sub.ifr_name)-1] = 0;
if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifr_sub) < 0) {
fprintf(stderr, "SIOCGIFFLAGS failed for %s.\n",
ifr->ifr_name);
@@ -287,7 +292,7 @@ int get_interfaces()
}
np->ifindex = ifr_sub.ifr_ifindex;
- np->ifname = (char *)malloc(sizeof(ifr->ifr_name));
+ np->ifname = strdup(ifr->ifr_name);
if (np->ifname == NULL)
{
fprintf(stderr, "get_interfaces: malloc failed\n");
@@ -302,8 +307,6 @@ int get_interfaces()
return -1;
}
- strncpy(np->ifname, ifr->ifr_name, sizeof(ifr->ifr_name));
-
if (ioctl(sock, SIOCGIFHWADDR, &ifr_sub) < 0) {
fprintf(stderr, "SIOCGIFHWADDR failed for %s.\n",
ifr_sub.ifr_name);
@@ -403,7 +406,6 @@ int networkio(int argc, char *argv[])
*/
bzero(packetbuf, sizeof(packetbuf));
bzero(&from, sizeof(from));
- len = sizeof(from);
rsock_fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_LOOP));
memset(&rcv_info, 0, sizeof(rcv_info));
@@ -449,6 +451,7 @@ int networkio(int argc, char *argv[])
*/
count = 0;
do {
+ len = sizeof(from);
cc = recvfrom(rsock_fd, packetbuf, sizeof(packetbuf),
MSG_DONTWAIT, (struct sockaddr *)&from, &len);