Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 12:51:15 +02:00
commit 27c9d80f51
10493 changed files with 1885777 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -131,7 +131,7 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$
#
if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
- @set -e; \
+ +@set -e; \
$(echo-cmd) $(cmd_$(1)); \
echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
@@ -140,7 +140,7 @@ if_changed = $(if $(strip $(filter-out $
if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
$(filter-out FORCE $(wildcard $^),$^) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
- @set -e; \
+ +@set -e; \
$(echo-cmd) $(cmd_$(1)); \
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
rm -f $(depfile); \
@@ -151,5 +151,5 @@ if_changed_dep = $(if $(strip $(filter-o
# and if so will execute $(rule_foo)
if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
- @set -e; \
+ +@set -e; \
$(rule_$(1)))

View File

@@ -0,0 +1,18 @@
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -722,6 +722,7 @@ static int bcast_or_ucast(struct dhcp_pa
static NOINLINE int send_discover(uint32_t requested)
{
struct dhcp_packet packet;
+ static int msgs = 0;
/* Fill in: op, htype, hlen, cookie, chaddr fields,
* xid field, message type option:
@@ -736,6 +737,7 @@ static NOINLINE int send_discover(uint32
*/
add_client_options(&packet);
+ if (msgs++ < 3)
bb_simple_info_msg("broadcasting discover");
return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
}

View File

@@ -0,0 +1,15 @@
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1384,6 +1384,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
struct pollfd pfds[2];
struct dhcp_packet packet;
+ /* When running on a bridge, the ifindex may have changed (e.g. if
+ * member interfaces were added/removed or if the status of the
+ * bridge changed).
+ * Workaround: refresh it here before processing the next packet */
+ udhcp_read_interface(client_data.interface, &client_data.ifindex, NULL, client_data.client_mac);
+
//bb_error_msg("sockfd:%d, listen_mode:%d", client_data.sockfd, client_data.listen_mode);
/* Was opening raw or udp socket here

View File

@@ -0,0 +1,79 @@
--- /dev/null
+++ b/networking/netmsg.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name>
+ *
+ * This is free software, licensed under the GNU General Public License v2.
+ */
+
+//config:config NETMSG
+//config: bool "netmsg"
+//config: default n
+//config: help
+//config: simple program for sending udp broadcast messages
+
+//applet:IF_NETMSG(APPLET(netmsg, BB_DIR_BIN, BB_SUID_REQUIRE))
+
+//kbuild:lib-$(CONFIG_NETMSG) += netmsg.o
+
+//usage:#define netmsg_trivial_usage NOUSAGE_STR
+//usage:#define netmsg_full_usage ""
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "busybox.h"
+
+#ifndef CONFIG_NETMSG
+int main(int argc, char **argv)
+#else
+int netmsg_main(int argc, char **argv)
+#endif
+{
+ int s;
+ struct sockaddr_in addr;
+ int optval = 1;
+ unsigned char buf[1001];
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
+ exit(1);
+ }
+
+ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ perror("Opening socket");
+ exit(1);
+ }
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr(argv[1]);
+ addr.sin_port = htons(0x1337);
+
+ memset(buf, 0, 1001);
+ buf[0] = 0xde;
+ buf[1] = 0xad;
+
+ strncpy(buf + 2, argv[2], 998);
+
+ if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
+ perror("setsockopt()");
+ goto fail;
+ }
+
+ if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ perror("sendto()");
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ close(s);
+ exit(1);
+}

View File

@@ -0,0 +1,158 @@
--- /dev/null
+++ b/miscutils/lock.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name>
+ *
+ * This is free software, licensed under the GNU General Public License v2.
+ */
+
+//config:config LOCK
+//config: bool "lock"
+//config: default n
+//config: help
+//config: Small utility for using locks in scripts
+
+//applet:IF_LOCK(APPLET(lock, BB_DIR_BIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_LOCK) += lock.o
+
+//usage:#define lock_trivial_usage NOUSAGE_STR
+//usage:#define lock_full_usage ""
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "busybox.h"
+
+static int unlock = 0;
+static int shared = 0;
+static int waitonly = 0;
+static int try_lock = 0;
+static int fd;
+static char *file;
+
+static void usage(char *name)
+{
+ fprintf(stderr, "Usage: %s [-suw] <filename>\n"
+ " -s Use shared locking\n"
+ " -u Unlock\n"
+ " -w Wait for the lock to become free, don't acquire lock\n"
+ " -n Don't wait for the lock to become free. Fail with exit code\n"
+ "\n", name);
+ exit(1);
+}
+
+static void exit_unlock(int sig)
+{
+ flock(fd, LOCK_UN);
+ exit(0);
+}
+
+static int do_unlock(void)
+{
+ FILE *f;
+ int i;
+
+ if ((f = fopen(file, "r")) == NULL)
+ return 0;
+
+ fscanf(f, "%d", &i);
+ if (i > 0)
+ kill(i, SIGTERM);
+
+ fclose(f);
+
+ return 0;
+}
+
+static int do_lock(void)
+{
+ pid_t pid;
+ int flags;
+ char pidstr[12];
+
+ if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) {
+ if ((fd = open(file, O_RDWR)) < 0) {
+ fprintf(stderr, "Can't open %s\n", file);
+ return 1;
+ }
+ }
+
+ flags = shared ? LOCK_SH : LOCK_EX;
+ flags |= try_lock ? LOCK_NB : 0;
+
+ if (flock(fd, flags) < 0) {
+ fprintf(stderr, "Can't lock %s\n", file);
+ return 1;
+ }
+
+ pid = fork();
+
+ if (pid < 0)
+ return -1;
+
+ if (pid == 0) {
+ signal(SIGKILL, exit_unlock);
+ signal(SIGTERM, exit_unlock);
+ signal(SIGINT, exit_unlock);
+ if (waitonly)
+ exit_unlock(0);
+ else
+ while (1)
+ sleep(1);
+ } else {
+ if (!waitonly) {
+ lseek(fd, 0, SEEK_SET);
+ ftruncate(fd, 0);
+ snprintf(pidstr, sizeof(pidstr), "%d\n", pid);
+ write(fd, pidstr, strlen(pidstr));
+ close(fd);
+ }
+
+ return 0;
+ }
+ return 0;
+}
+
+int lock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int lock_main(int argc, char **argv)
+{
+ char **args = &argv[1];
+ int c = argc - 1;
+
+ while ((*args != NULL) && (*args)[0] == '-') {
+ char *ch = *args;
+ while (*(++ch) > 0) {
+ switch(*ch) {
+ case 'w':
+ waitonly = 1;
+ break;
+ case 's':
+ shared = 1;
+ break;
+ case 'u':
+ unlock = 1;
+ break;
+ case 'n':
+ try_lock = 1;
+ break;
+ }
+ }
+ c--;
+ args++;
+ }
+
+ if (c != 1)
+ usage(argv[0]);
+
+ file = *args;
+ if (unlock)
+ return do_unlock();
+ else
+ return do_lock();
+}

View File

@@ -0,0 +1,20 @@
--- a/libbb/printable_string.c
+++ b/libbb/printable_string.c
@@ -28,8 +28,6 @@ const char* FAST_FUNC printable_string2(
}
if (c < ' ')
break;
- if (c >= 0x7f)
- break;
s++;
}
@@ -42,7 +40,7 @@ const char* FAST_FUNC printable_string2(
unsigned char c = *d;
if (c == '\0')
break;
- if (c < ' ' || c >= 0x7f)
+ if (c < ' ')
*d = '?';
d++;
}

View File

@@ -0,0 +1,11 @@
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -683,7 +683,7 @@ static int do_add_or_delete(char **argv,
}
xrtnl_open(&rth);
ll_init_map(&rth);
- if (type_str) {
+ if (type_str && rtm == RTM_NEWLINK) {
struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);

View File

@@ -0,0 +1,13 @@
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -236,8 +236,8 @@
//config: depends on TRACEROUTE || TRACEROUTE6
/* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */
-//applet:IF_TRACEROUTE(APPLET(traceroute, BB_DIR_USR_BIN, BB_SUID_MAYBE))
-//applet:IF_TRACEROUTE6(APPLET(traceroute6, BB_DIR_USR_BIN, BB_SUID_MAYBE))
+//applet:IF_TRACEROUTE(APPLET(traceroute, BB_DIR_BIN, BB_SUID_MAYBE))
+//applet:IF_TRACEROUTE6(APPLET(traceroute6, BB_DIR_BIN, BB_SUID_MAYBE))
//kbuild:lib-$(CONFIG_TRACEROUTE) += traceroute.o
//kbuild:lib-$(CONFIG_TRACEROUTE6) += traceroute.o

View File

@@ -0,0 +1,11 @@
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -23,7 +23,7 @@
//config: With this option passwd will refuse new passwords which are "weak".
//applet:/* Needs to be run by root or be suid root - needs to change /etc/{passwd,shadow}: */
-//applet:IF_PASSWD(APPLET(passwd, BB_DIR_USR_BIN, BB_SUID_REQUIRE))
+//applet:IF_PASSWD(APPLET(passwd, BB_DIR_BIN, BB_SUID_REQUIRE))
//kbuild:lib-$(CONFIG_PASSWD) += passwd.o

View File

@@ -0,0 +1,53 @@
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -89,6 +89,11 @@ int chpasswd_main(int argc UNUSED_PARAM,
crypt_make_pw_salt(salt, algo);
free_me = pass = pw_encrypt(pass, salt, 0);
+
+ if (pass[0] == 0) {
+ free(free_me);
+ bb_perror_msg_and_die("password encryption failed");
+ }
}
/* This is rather complex: if user is not found in /etc/shadow,
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -87,7 +87,7 @@ int cryptpw_main(int argc UNUSED_PARAM,
/* Supports: cryptpw -m sha256 PASS 'rounds=999999999$SALT' */
char salt[MAX_PW_SALT_LEN + sizeof("rounds=999999999$")];
char *salt_ptr;
- char *password;
+ char *password, *hash;
const char *opt_m, *opt_S;
int fd;
@@ -132,8 +132,12 @@ int cryptpw_main(int argc UNUSED_PARAM,
/* may still be NULL on EOF/error */
}
- if (password)
- puts(pw_encrypt(password, salt, 1));
+ if (password) {
+ hash = pw_encrypt(password, salt, 1);
+ if (hash[0] == 0)
+ bb_perror_msg_and_die("password encryption failed");
+ puts(hash);
+ }
return EXIT_SUCCESS;
}
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -187,6 +187,10 @@ int passwd_main(int argc UNUSED_PARAM, c
if (!newp) {
logmode = LOGMODE_STDIO;
bb_error_msg_and_die("password for %s is unchanged", name);
+ } else if (newp[0] == 0) {
+ logmode = LOGMODE_STDIO;
+ free(newp);
+ bb_perror_msg_and_die("password encryption failed");
}
} else if (opt & OPT_lock) {
if (!c)

View File

@@ -0,0 +1,42 @@
From: Uwe Kleine-König <uwe@kleine-koenig.org>
Date: Sat, 8 Oct 2022 19:22:52 +0200
Subject: [PATCH] nslookup: ensure unique transaction IDs for the DNS queries
The transaction IDs generated by res_mkquery() for both glibc and musl only
depends on the state of the monotonic clock.
For some machines (here: a TP-Link RE200 powered by a MediaTek MT7620A)
the monotonic clock has a coarse resolution (here: 20 µs) and it can happen
that the requests for A and AAAA share the same transaction ID.
In that case the mapping from received responses to the sent queries
doesn't work and name resolution fails as follows:
# /bin/busybox nslookup heise.de
Server: 127.0.0.1
Address: 127.0.0.1:53
Non-authoritative answer:
Name: heise.de
Address: 193.99.144.80
*** Can't find heise.de: No answer
because the AAAA reply is dropped as a duplicate reply to the A query.
To prevent this make sure the transaction IDs are unique.
Forwarded: http://lists.busybox.net/pipermail/busybox/2022-October/089911.html
---
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -978,6 +978,10 @@ int nslookup_main(int argc UNUSED_PARAM,
}
}
+ /* Ensure the Transaction IDs are unique */
+ for (rc = 1; rc < G.query_count; rc++)
+ G.query[rc].query[1] = G.query[rc - 1].query[1] + 1;
+
for (rc = 0; rc < G.serv_count;) {
int c;