Fwd: Can I send a patch for busybox mainline?

Ys Cho via busybox <[email protected]>
Newsgroups gmane.linux.busybox
Message-ID <CAPp144Rz=Zbqvkg0oaCKFErv8tmqLiif2STO-zu7=nS6CiZjrg@mail.gmail.com>
---------- Forwarded message ---------
보낸사람: Ys Cho <[email protected]>
Date: 2026년 8월 15일 (토) 오후 11:51
Subject: Can I send a patch for busybox mainline?
To: <[email protected]>


There are too many annoying compiler warnings and type mismatches, so I
fixed some issues...
I hope it would help

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox
busybox.patch (application/x-patch, 16.9 KB)
diff --git a/coreutils/id.c b/coreutils/id.c
index a4f178bda..319e80c0c 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -156,7 +156,7 @@ int id_main(int argc UNUSED_PARAM, char **argv)
 	const char *prefix;
 	const char *username;
 #if ENABLE_SELINUX
-	security_context_t scontext = NULL;
+	char *scontext = NULL;
 #endif
 
 	if (ENABLE_GROUPS && (!ENABLE_ID || applet_name[0] == 'g')) {
diff --git a/coreutils/install.c b/coreutils/install.c
index 00f8be87e..b6d1067ea 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -70,10 +70,12 @@ static const char install_longopts[] ALIGN1 =
 
 
 #if ENABLE_SELINUX
+#include <selinux/label.h>
 static void setdefaultfilecon(const char *path)
 {
 	struct stat s;
-	security_context_t scontext = NULL;
+	struct selabel_handle *handle;
+	char *scontext = NULL;
 
 	if (!is_selinux_enabled()) {
 		return;
@@ -82,7 +84,12 @@ static void setdefaultfilecon(const char *path)
 		return;
 	}
 
-	if (matchpathcon(path, s.st_mode, &scontext) < 0) {
+	// is that enough to pass these parameters?
+	handle = selabel_open(SELABEL_CTX_FILE, NULL, 0);
+	if (!handle) {
+		goto out;
+	}
+	if (selabel_lookup(handle, &scontext, path, s.st_mode) < 0) {
 		goto out;
 	}
 	if (strcmp(scontext, "<<none>>") == 0) {
@@ -97,6 +104,9 @@ static void setdefaultfilecon(const char *path)
 	}
 
  out:
+	if(handle) {
+		selabel_close(handle);
+	}
 	freecon(scontext);
 }
 
@@ -119,7 +129,7 @@ int install_main(int argc, char **argv)
 	int ret = EXIT_SUCCESS;
 	int isdir;
 #if ENABLE_SELINUX
-	security_context_t scontext;
+	char *scontext;
 	bool use_default_selinux_context = 1;
 #endif
 	enum {
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
index dafe70edf..938adef18 100644
--- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c
+++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
@@ -26,7 +26,7 @@ mode_t FAST_FUNC getopt_mk_fifo_nod(char **argv)
 	mode_t mode = 0666;
 	char *smode = NULL;
 #if ENABLE_SELINUX
-	security_context_t scontext;
+	char *scontext;
 #endif
 	int opt;
 	opt = getopt32(argv, "m:" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 40017efc6..9f5217405 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -311,7 +311,7 @@ struct dnode {
 	const char *name;       /* usually basename, but think "ls -l dir/file" */
 	const char *fullname;   /* full name (usable for stat etc) */
 	struct dnode *dn_next;  /* for linked list */
-	IF_SELINUX(security_context_t sid;)
+	IF_SELINUX(char *sid;)
 	smallint fname_allocated;
 
 	/* Used to avoid re-doing [l]stat at printout stage
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index e074c3561..6ba4141d3 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -57,7 +57,7 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
 	unsigned opt;
 	char *smode;
 #if ENABLE_SELINUX
-	security_context_t scontext;
+	char *scontext;
 #endif
 
 	opt = getopt32long(argv, "m:pv" IF_SELINUX("Z:"),
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 2c2909e7e..8efeae1e1 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -258,7 +258,7 @@ static void printfs(char *pformat, const char *msg)
 /* print statfs info */
 static void FAST_FUNC print_statfs(char *pformat, const char m,
 		const char *const filename, const void *data
-		IF_SELINUX(, security_context_t scontext))
+		IF_SELINUX(, char *scontext))
 {
 	const struct statfs *statfsbuf = data;
 	if (m == 'n') {
@@ -306,7 +306,7 @@ static void FAST_FUNC print_statfs(char *pformat, const char m,
 /* print stat info */
 static void FAST_FUNC print_stat(char *pformat, const char m,
 		const char *const filename, const void *data
-		IF_SELINUX(, security_context_t scontext))
+		IF_SELINUX(, char *scontext))
 {
 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
 	struct stat *statbuf = (struct stat *) data;
@@ -408,9 +408,9 @@ static void FAST_FUNC print_stat(char *pformat, const char m,
 
 static void print_it(const char *masterformat,
 		const char *filename,
-		void FAST_FUNC (*print_func)(char*, char, const char*, const void* IF_SELINUX(, security_context_t scontext)),
+		void FAST_FUNC (*print_func)(char*, char, const char*, const void* IF_SELINUX(, char *scontext)),
 		const void *data
-		IF_SELINUX(, security_context_t scontext))
+		IF_SELINUX(, char *scontext))
 {
 	/* Create a working copy of the format string */
 	char *format = xstrdup(masterformat);
@@ -475,7 +475,7 @@ static bool do_statfs(const char *filename, const char *format)
 	const char *format;
 #endif
 #if ENABLE_SELINUX
-	security_context_t scontext = NULL;
+	char *scontext = NULL;
 
 	if (option_mask32 & OPT_SELINUX) {
 		if ((option_mask32 & OPT_DEREFERENCE
@@ -590,7 +590,7 @@ static bool do_stat(const char *filename, const char *format)
 {
 	struct stat statbuf;
 #if ENABLE_SELINUX
-	security_context_t scontext = NULL;
+	char *scontext = NULL;
 
 	if (option_mask32 & OPT_SELINUX) {
 		if ((option_mask32 & OPT_DEREFERENCE
diff --git a/findutils/find.c b/findutils/find.c
index 31c996988..b876fec8b 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -467,7 +467,7 @@ IF_FEATURE_FIND_INUM(   ACTS(inum,  ino_t inode_num;))
 IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;))
 IF_FEATURE_FIND_USER(   ACTS(user,  uid_t uid;))
 IF_FEATURE_FIND_SIZE(   ACTS(size,  char size_char; off_t size;))
-IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;))
+IF_FEATURE_FIND_CONTEXT(ACTS(context, char *context;))
 IF_FEATURE_FIND_PAREN(  ACTS(paren, action ***subexpr;))
 IF_FEATURE_FIND_PRUNE(  ACTS(prune))
 IF_FEATURE_FIND_QUIT(   ACTS(quit))
@@ -983,7 +983,7 @@ ACTF(empty)
 #if ENABLE_FEATURE_FIND_CONTEXT
 ACTF(context)
 {
-	security_context_t con;
+	char *con;
 	int rc;
 
 	if (G.recurse_flags & ACTION_FOLLOWLINKS) {
diff --git a/include/libbb.h b/include/libbb.h
index 873149b7c..28e7f5c1f 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1882,10 +1882,10 @@ void getcaps(void *caps) FAST_FUNC;
 
 #if ENABLE_SELINUX
 extern void renew_current_security_context(void) FAST_FUNC;
-extern void set_current_security_context(security_context_t sid) FAST_FUNC;
-extern context_t set_security_context_component(security_context_t cur_context,
+extern void set_current_security_context(char *sid) FAST_FUNC;
+extern context_t set_security_context_component(char *cur_context,
 						char *user, char *role, char *type, char *range) FAST_FUNC;
-extern void setfscreatecon_or_die(security_context_t scontext) FAST_FUNC;
+extern void setfscreatecon_or_die(char *scontext) FAST_FUNC;
 extern void selinux_preserve_fcontext(int fdesc) FAST_FUNC;
 #else
 #define selinux_preserve_fcontext(fdesc) ((void)0)
diff --git a/libbb/run_shell.c b/libbb/run_shell.c
index c22bba87b..1c366d069 100644
--- a/libbb/run_shell.c
+++ b/libbb/run_shell.c
@@ -33,14 +33,14 @@
 #endif
 
 #if ENABLE_SELINUX
-static security_context_t current_sid;
+static char *current_sid;
 
 void FAST_FUNC renew_current_security_context(void)
 {
 	freecon(current_sid);  /* Release old context  */
 	getcon(&current_sid);  /* update */
 }
-void FAST_FUNC set_current_security_context(security_context_t sid)
+void FAST_FUNC set_current_security_context(char *sid)
 {
 	freecon(current_sid);  /* Release old context  */
 	current_sid = sid;
diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c
index f917a1c6a..8f00f2db5 100644
--- a/libbb/selinux_common.c
+++ b/libbb/selinux_common.c
@@ -9,7 +9,7 @@
 #include "libbb.h"
 #include <selinux/context.h>
 
-context_t FAST_FUNC set_security_context_component(security_context_t cur_context,
+context_t FAST_FUNC set_security_context_component(char *cur_context,
 			char *user, char *role, char *type, char *range)
 {
 	context_t con = context_new(cur_context);
@@ -31,7 +31,7 @@ error:
 	return NULL;
 }
 
-void FAST_FUNC setfscreatecon_or_die(security_context_t scontext)
+void FAST_FUNC setfscreatecon_or_die(char *scontext)
 {
 	if (setfscreatecon(scontext) < 0) {
 		/* Can be NULL. All known printf implementations
@@ -43,7 +43,7 @@ void FAST_FUNC setfscreatecon_or_die(security_context_t scontext)
 
 void FAST_FUNC selinux_preserve_fcontext(int fdesc)
 {
-	security_context_t context;
+	char *context;
 
 	if (fgetfilecon(fdesc, &context) < 0) {
 		if (errno == ENODATA || errno == ENOTSUP)
diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c
index a228075cc..b8a47dc5a 100644
--- a/libbb/update_passwd.c
+++ b/libbb/update_passwd.c
@@ -18,7 +18,7 @@
 #if ENABLE_SELINUX
 static void check_selinux_update_passwd(const char *username)
 {
-	security_context_t seuser;
+	char *seuser;
 	char *p;
 
 	if (getuid() != (uid_t)0 || is_selinux_enabled() == 0)
diff --git a/loginutils/login.c b/loginutils/login.c
index 301be4a34..16e009496 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -181,9 +181,9 @@ static void die_if_nologin(void)
 
 #if ENABLE_SELINUX
 static void initselinux(char *username, char *full_tty,
-						security_context_t *user_sid)
+						char **user_sid)
 {
-	security_context_t old_tty_sid, new_tty_sid;
+	char *old_tty_sid, *new_tty_sid;
 
 	if (!is_selinux_enabled())
 		return;
@@ -333,7 +333,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
 	char *opt_user = opt_user; /* for compiler */
 	char *full_tty;
 	char *short_tty;
-	IF_SELINUX(security_context_t user_sid = NULL;)
+	IF_SELINUX(char *user_sid = NULL;)
 #if ENABLE_PAM
 	int pamret;
 	pam_handle_t *pamh;
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index d57691414..d9bc7a400 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -1016,10 +1016,10 @@ static void restore(char *spath, struct stat source_stat, int rootlen)
 	dest_stat.st_mode = 0;
 	dpath = concat_path_file(mount_point, spath + rootlen);
 	lstat(dpath, &dest_stat);
-	free(dpath);
 	if (S_ISLNK(source_stat.st_mode) || (source_stat.st_mode & S_ISVTX))
 		copy_inode(dpath, &dest_stat, (source_stat.st_mode & ~S_ISVTX), spath, &source_stat);
 
+	free(dpath);
 	if (S_ISDIR(source_stat.st_mode))
 		dir_operation(RESTORE, spath, rootlen, NULL);
 }
@@ -1271,7 +1271,7 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
 
 	while ((de = readdir(dp)) != NULL) {
 
-		if (de->d_name && DOT_OR_DOTDOT(de->d_name))
+		if (DOT_OR_DOTDOT(de->d_name))
 			continue;
 		path = concat_path_file(dir_name, de->d_name);
 		if (lstat(path, &statbuf) == 0) {
diff --git a/miscutils/less.c b/miscutils/less.c
index 87f44a324..8974f9201 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -469,7 +469,7 @@ static int at_end(void)
  */
 static void read_lines(void)
 {
-	int ndelay_set, eagain, fdflags;
+	int ndelay_set, eagain, fdflags = 0;
 	char *current_line, *p;
 	int w = width;
 	char last_terminated = terminated;
@@ -543,8 +543,9 @@ static void read_lines(void)
 			if (c == '\x8' && last_line_pos && p[-1] != '\t') {
 				readpos++; /* eat it */
 				last_line_pos--;
+				p--;
 			/* was buggy (p could end up <= current_line)... */
-				*--p = '\0';
+				*p = '\0';
 				continue;
 			}
 #if ENABLE_FEATURE_LESS_RAW
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 862f71f57..b8f52b672 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -105,6 +105,7 @@ char* FAST_FUNC filename2modname(const char *filename, char *modname)
 	if (modname == local_modname)
 		return xstrdup(modname);
 
+	// Should modname != local_modname at this moment. Warning is not problem.
 	return modname;
 }
 
diff --git a/networking/inetd.c b/networking/inetd.c
index 6220a08e3..af9996533 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1043,7 +1043,8 @@ static void reread_config_file(int sig UNUSED_PARAM)
 			portno = bb_strtou(sep->se_service, NULL, 10);
 #if ENABLE_FEATURE_INETD_RPC
 			if (is_rpc_service(sep)) {
-				sep->se_rpcprog = n;
+				// FIXME n is not defined here. what value I should put in?
+				// sep->se_rpcprog = n;
 				if (errno) { /* se_service is not numeric */
 					struct rpcent *rp = getrpcbyname(sep->se_service);
 					if (rp == NULL) {
diff --git a/networking/tc.c b/networking/tc.c
index 3a79fd2d9..8dbbc9cb6 100644
--- a/networking/tc.c
+++ b/networking/tc.c
@@ -231,6 +231,7 @@ static int cbq_parse_opt(int argc, char **argv, struct nlmsghdr *n)
 	return 0;
 }
 #endif
+// This function is fully broken. Where these symbols are from?
 static int cbq_print_opt(struct rtattr *opt)
 {
 	struct rtattr *tb[TCA_CBQ_MAX+1];
diff --git a/networking/tftp.c b/networking/tftp.c
index b698a9288..9444200a4 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -883,7 +883,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
 	len_and_sockaddr *our_lsa;
 	len_and_sockaddr *peer_lsa;
 	char *mode, *user_opt;
-	char *local_file = local_file;
+	char *local_file = NULL;
 	const char *error_msg;
 	int opt, result, opcode;
 	IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;)
diff --git a/selinux/chcon.c b/selinux/chcon.c
index e1778a36a..a67220a81 100644
--- a/selinux/chcon.c
+++ b/selinux/chcon.c
@@ -67,8 +67,8 @@ static int FAST_FUNC change_filedir_context(struct recursive_state *state UNUSED
 		struct stat *stbuf UNUSED_PARAM)
 {
 	context_t context = NULL;
-	security_context_t file_context = NULL;
-	security_context_t context_string;
+	char *file_context = NULL;
+	char *context_string;
 	int rc = FALSE;
 	int status = 0;
 
@@ -103,7 +103,7 @@ static int FAST_FUNC change_filedir_context(struct recursive_state *state UNUSED
 		}
 	}
 
-	context_string = context_str(context);
+	context_string = (char*)context_str(context);
 	if (!context_string) {
 		bb_simple_error_msg("can't obtain security context in text expression");
 		goto skip;
diff --git a/selinux/matchpathcon.c b/selinux/matchpathcon.c
index 6945a0295..456209bbd 100644
--- a/selinux/matchpathcon.c
+++ b/selinux/matchpathcon.c
@@ -80,7 +80,7 @@ int matchpathcon_main(int argc UNUSED_PARAM, char **argv)
 	}
 
 	while ((path = *argv++) != NULL) {
-		security_context_t con;
+		char *con;
 		int rc;
 
 		if (!(opts & OPT_VERIFY)) {
diff --git a/selinux/runcon.c b/selinux/runcon.c
index bc4fa23e0..343b6563d 100644
--- a/selinux/runcon.c
+++ b/selinux/runcon.c
@@ -62,13 +62,13 @@ static context_t runcon_compute_new_context(char *user, char *role, char *type,
 			char *command, int compute_trans)
 {
 	context_t con;
-	security_context_t cur_context;
+	char *cur_context;
 
 	if (getcon(&cur_context))
 		bb_simple_error_msg_and_die("can't get current context");
 
 	if (compute_trans) {
-		security_context_t file_context, new_context;
+		char *file_context, *new_context;
 
 		if (getfilecon(command, &file_context) < 0)
 			bb_error_msg_and_die("can't retrieve attributes of '%s'",
diff --git a/selinux/sestatus.c b/selinux/sestatus.c
index cf664cc18..4a82338fb 100644
--- a/selinux/sestatus.c
+++ b/selinux/sestatus.c
@@ -92,7 +92,7 @@ static void read_config(char **pc, int npc, char **fc, int nfc)
 
 static void display_verbose(void)
 {
-	security_context_t con, _con;
+	char *con, *_con;
 	char *fc[50], *pc[50], *cterm;
 	pid_t *pidList;
 	int i;
diff --git a/shell/hush.c b/shell/hush.c
index d1e954485..268743a3c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7183,9 +7183,9 @@ static NOINLINE int expand_one_var(o_string *output, int n, char *arg, char **pp
 	char *p;
 	char *var;
 	char exp_op;
-	char exp_save = exp_save; /* for compiler */
+	char exp_save = 0; /* for compiler */
 	char *exp_saveptr; /* points to expansion operator */
-	char *exp_word = exp_word; /* for compiler */
+	char *exp_word = NULL; /* for compiler */
 	char arg0;
 
 	val = NULL;
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index bca3de199..2e5356769 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -49,8 +49,8 @@ static void mkswap_selinux_setcontext(int fd, const char *path)
 
 	xfstat(fd, &stbuf, path);
 	if (S_ISREG(stbuf.st_mode)) {
-		security_context_t newcon;
-		security_context_t oldcon = NULL;
+		char *newcon;
+		char *oldcon = NULL;
 		context_t context;
 
 		if (fgetfilecon(fd, &oldcon) < 0) {
@@ -62,7 +62,7 @@ static void mkswap_selinux_setcontext(int fd, const char *path)
 		context = context_new(oldcon);
 		if (!context || context_type_set(context, "swapfile_t"))
 			goto error;
-		newcon = context_str(context);
+		newcon = (char*)context_str(context);
 		if (!newcon)
 			goto error;
 		/* fsetfilecon_raw is hidden */
diff --git a/util-linux/volume_id/btrfs.c b/util-linux/volume_id/btrfs.c
index a3ddf9782..1b0a69a87 100644
--- a/util-linux/volume_id/btrfs.c
+++ b/util-linux/volume_id/btrfs.c
@@ -90,10 +90,10 @@ int FAST_FUNC volume_id_probe_btrfs(struct volume_id *id /*,uint64_t off*/)
 	// minimum btrfs size is 256M
 	// so we never step out the device if we analyze
 	// the first and the second superblocks
-	struct btrfs_super_block *sb;
+	struct btrfs_super_block *sb = NULL;
 	unsigned off = 64;
 
-	while (off < 64*1024*1024) {
+	do {
 		off *= 1024;
 		dbg("btrfs: probing at offset 0x%x", off);
 
@@ -103,7 +103,7 @@ int FAST_FUNC volume_id_probe_btrfs(struct volume_id *id /*,uint64_t off*/)
 
 		if (memcmp(sb->magic, BTRFS_MAGIC, 8) != 0)
 			return -1;
-	}
+	} while (off < 64*1024*1024);
 
 	// N.B.: btrfs natively supports 256 (>VOLUME_ID_LABEL_SIZE) size labels
 	volume_id_set_label_string(id, sb->label, VOLUME_ID_LABEL_SIZE);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.