mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
taskset: fix incorrect rage spec and allow 0xXXX input
ping: shave off 60 bytes
This commit is contained in:
parent
86811803e3
commit
e935602ff5
@ -62,7 +62,7 @@ int taskset_main(int argc, char** argv)
|
|||||||
aff = *++argv; /* <aff> <cmd...> */
|
aff = *++argv; /* <aff> <cmd...> */
|
||||||
if (aff) {
|
if (aff) {
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
unsigned long l = xstrtol_range(aff, 16, 1, ULONG_MAX);
|
unsigned long l = xstrtol_range(aff, 0, 1, LONG_MAX);
|
||||||
|
|
||||||
CPU_ZERO(&new_mask);
|
CPU_ZERO(&new_mask);
|
||||||
while (i < CPU_SETSIZE && l >= (1<<i)) {
|
while (i < CPU_SETSIZE && l >= (1<<i)) {
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <netinet/ip_icmp.h>
|
#include <netinet/ip_icmp.h>
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
#if ENABLE_PING6
|
#if ENABLE_PING6
|
||||||
#include <netinet/icmp6.h>
|
#include <netinet/icmp6.h>
|
||||||
/* I see RENUMBERED constants in bits/in.h - !!?
|
/* I see RENUMBERED constants in bits/in.h - !!?
|
||||||
@ -85,7 +86,7 @@ static void noresp(int ign ATTRIBUTE_UNUSED)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ping(len_and_sockaddr *lsa)
|
static void ping4(len_and_sockaddr *lsa)
|
||||||
{
|
{
|
||||||
struct sockaddr_in pingaddr;
|
struct sockaddr_in pingaddr;
|
||||||
struct icmp *pkt;
|
struct icmp *pkt;
|
||||||
@ -222,7 +223,7 @@ int ping_main(int argc, char **argv)
|
|||||||
ping6(lsa);
|
ping6(lsa);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
ping(lsa);
|
ping4(lsa);
|
||||||
printf("%s is alive!\n", hostname);
|
printf("%s is alive!\n", hostname);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -300,7 +301,25 @@ static void pingstats(int junk ATTRIBUTE_UNUSED)
|
|||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendping(int junk ATTRIBUTE_UNUSED)
|
static void sendping_tail(void (*sp)(int), int sz, int sizeof_packet)
|
||||||
|
{
|
||||||
|
if (sz < 0)
|
||||||
|
bb_perror_msg_and_die("sendto");
|
||||||
|
if (sz != sizeof_packet)
|
||||||
|
bb_error_msg_and_die("ping wrote %d chars; %d expected", sz,
|
||||||
|
sizeof_packet);
|
||||||
|
|
||||||
|
signal(SIGALRM, sp);
|
||||||
|
if (pingcount == 0 || ntransmitted < pingcount) { /* schedule next in 1s */
|
||||||
|
alarm(PINGINTERVAL);
|
||||||
|
} else { /* done, wait for the last ping to come back */
|
||||||
|
/* todo, don't necessarily need to wait so long... */
|
||||||
|
signal(SIGALRM, pingstats);
|
||||||
|
alarm(MAXWAIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sendping4(int junk ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
struct icmp *pkt;
|
struct icmp *pkt;
|
||||||
int i;
|
int i;
|
||||||
@ -322,20 +341,7 @@ static void sendping(int junk ATTRIBUTE_UNUSED)
|
|||||||
i = sendto(pingsock, packet, sizeof(packet), 0,
|
i = sendto(pingsock, packet, sizeof(packet), 0,
|
||||||
&pingaddr.sa, sizeof(pingaddr.sin));
|
&pingaddr.sa, sizeof(pingaddr.sin));
|
||||||
|
|
||||||
if (i < 0)
|
sendping_tail(sendping4, i, sizeof(packet));
|
||||||
bb_perror_msg_and_die("sendto");
|
|
||||||
if ((size_t)i != sizeof(packet))
|
|
||||||
bb_error_msg_and_die("ping wrote %d chars; %d expected", i,
|
|
||||||
(int)sizeof(packet));
|
|
||||||
|
|
||||||
signal(SIGALRM, sendping);
|
|
||||||
if (pingcount == 0 || ntransmitted < pingcount) { /* schedule next in 1s */
|
|
||||||
alarm(PINGINTERVAL);
|
|
||||||
} else { /* done, wait for the last ping to come back */
|
|
||||||
/* todo, don't necessarily need to wait so long... */
|
|
||||||
signal(SIGALRM, pingstats);
|
|
||||||
alarm(MAXWAIT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if ENABLE_PING6
|
#if ENABLE_PING6
|
||||||
static void sendping6(int junk ATTRIBUTE_UNUSED)
|
static void sendping6(int junk ATTRIBUTE_UNUSED)
|
||||||
@ -359,20 +365,7 @@ static void sendping6(int junk ATTRIBUTE_UNUSED)
|
|||||||
i = sendto(pingsock, packet, sizeof(packet), 0,
|
i = sendto(pingsock, packet, sizeof(packet), 0,
|
||||||
&pingaddr.sa, sizeof(pingaddr.sin6));
|
&pingaddr.sa, sizeof(pingaddr.sin6));
|
||||||
|
|
||||||
if (i < 0)
|
sendping_tail(sendping6, i, sizeof(packet));
|
||||||
bb_perror_msg_and_die("sendto");
|
|
||||||
if ((size_t)i != sizeof(packet))
|
|
||||||
bb_error_msg_and_die("ping wrote %d chars; %d expected", i,
|
|
||||||
(int)sizeof(packet));
|
|
||||||
|
|
||||||
signal(SIGALRM, sendping6);
|
|
||||||
if (pingcount == 0 || ntransmitted < pingcount) { /* schedule next in 1s */
|
|
||||||
alarm(PINGINTERVAL);
|
|
||||||
} else { /* done, wait for the last ping to come back */
|
|
||||||
/* todo, don't necessarily need to wait so long... */
|
|
||||||
signal(SIGALRM, pingstats);
|
|
||||||
alarm(MAXWAIT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -424,7 +417,7 @@ static char *icmp6_type_name(int id)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void unpack(char *buf, int sz, struct sockaddr_in *from)
|
static void unpack4(char *buf, int sz, struct sockaddr_in *from)
|
||||||
{
|
{
|
||||||
struct icmp *icmppkt;
|
struct icmp *icmppkt;
|
||||||
struct iphdr *iphdr;
|
struct iphdr *iphdr;
|
||||||
@ -560,7 +553,7 @@ static void unpack6(char *packet, int sz, struct sockaddr_in6 *from, int hoplimi
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ping(len_and_sockaddr *lsa)
|
static void ping4(len_and_sockaddr *lsa)
|
||||||
{
|
{
|
||||||
char packet[datalen + MAXIPLEN + MAXICMPLEN];
|
char packet[datalen + MAXIPLEN + MAXICMPLEN];
|
||||||
int sockopt;
|
int sockopt;
|
||||||
@ -588,7 +581,7 @@ static void ping(len_and_sockaddr *lsa)
|
|||||||
signal(SIGINT, pingstats);
|
signal(SIGINT, pingstats);
|
||||||
|
|
||||||
/* start the ping's going ... */
|
/* start the ping's going ... */
|
||||||
sendping(0);
|
sendping4(0);
|
||||||
|
|
||||||
/* listen for replies */
|
/* listen for replies */
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -603,7 +596,7 @@ static void ping(len_and_sockaddr *lsa)
|
|||||||
bb_perror_msg("recvfrom");
|
bb_perror_msg("recvfrom");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unpack(packet, c, &from);
|
unpack4(packet, c, &from);
|
||||||
if (pingcount > 0 && nreceived >= pingcount)
|
if (pingcount > 0 && nreceived >= pingcount)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -730,7 +723,7 @@ int ping_main(int argc, char **argv)
|
|||||||
|
|
||||||
datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */
|
datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */
|
||||||
|
|
||||||
/* exactly one argument needed, -v and -q don't mix. So do 4, 6 */
|
/* exactly one argument needed, -v and -q don't mix */
|
||||||
opt_complementary = "=1:q--v:v--q";
|
opt_complementary = "=1:q--v:v--q";
|
||||||
getopt32(argc, argv, OPT_STRING, &opt_c, &opt_s, &opt_I);
|
getopt32(argc, argv, OPT_STRING, &opt_c, &opt_s, &opt_I);
|
||||||
if (option_mask32 & OPT_c) pingcount = xatoul(opt_c); // -c
|
if (option_mask32 & OPT_c) pingcount = xatoul(opt_c); // -c
|
||||||
@ -758,7 +751,7 @@ int ping_main(int argc, char **argv)
|
|||||||
ping6(lsa);
|
ping6(lsa);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
ping(lsa);
|
ping4(lsa);
|
||||||
pingstats(0);
|
pingstats(0);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user