aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-24 14:09:19 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-24 14:09:19 +0000
commitf7be20e70c27b0bed505710393a99d1b6f821ff1 (patch)
tree151940c339bd35b64734053bb656488c9dbc3daa
parentfcfb5c04bbaa52ae7df5d45bc3ddadcc9e935fa1 (diff)
downloadbusybox-w32-f7be20e70c27b0bed505710393a99d1b6f821ff1.tar.gz
busybox-w32-f7be20e70c27b0bed505710393a99d1b6f821ff1.tar.bz2
busybox-w32-f7be20e70c27b0bed505710393a99d1b6f821ff1.zip
nameif: extended matching (Nico Erfurth <masta@perlgolf.de>)
*: whitespace fixes function old new delta prepend_new_eth_table - 304 +304 nameif_main 620 684 +64 cc_macaddr 51 - -51 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 1/0 up/down: 368/-51) Total: 317 bytes
-rw-r--r--applets/applet_tables.c2
-rw-r--r--archival/unzip.c2
-rw-r--r--coreutils/echo.c2
-rw-r--r--coreutils/tr.c2
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/dev.c2
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/tag.c2
-rw-r--r--editors/sed_summary.htm2
-rw-r--r--examples/bootfloppy/bootfloppy.txt2
-rw-r--r--examples/devfsd.conf2
-rw-r--r--examples/udhcp/udhcpd.conf4
-rw-r--r--libbb/lineedit.c2
-rw-r--r--networking/Config.in13
-rw-r--r--networking/nameif.c230
-rw-r--r--util-linux/more.c2
14 files changed, 179 insertions, 90 deletions
diff --git a/applets/applet_tables.c b/applets/applet_tables.c
index 9f42ebf31..c16df06a7 100644
--- a/applets/applet_tables.c
+++ b/applets/applet_tables.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
65 i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666); 65 i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666);
66 if (i < 0) 66 if (i < 0)
67 return 1; 67 return 1;
68 dup2(i, 1); 68 dup2(i, 1);
69 69
70 /* Keep in sync with include/busybox.h! */ 70 /* Keep in sync with include/busybox.h! */
71 71
diff --git a/archival/unzip.c b/archival/unzip.c
index 118c99bcd..c7d39daef 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -66,7 +66,7 @@ typedef union {
66struct BUG_zip_header_must_be_26_bytes { 66struct BUG_zip_header_must_be_26_bytes {
67 char BUG_zip_header_must_be_26_bytes[ 67 char BUG_zip_header_must_be_26_bytes[
68 offsetof(zip_header_t, formatted.extra_len) + 2 == 68 offsetof(zip_header_t, formatted.extra_len) + 2 ==
69 ZIP_HEADER_LEN ? 1 : -1]; 69 ZIP_HEADER_LEN ? 1 : -1];
70}; 70};
71 71
72#define FIX_ENDIANNESS(zip_header) do { \ 72#define FIX_ENDIANNESS(zip_header) do { \
diff --git a/coreutils/echo.c b/coreutils/echo.c
index e39b466c0..771f610b0 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -293,6 +293,6 @@ int echo_main(int argc, char **argv)
293 } 293 }
294 ret: 294 ret:
295 /* TODO: implement and use full_writev? */ 295 /* TODO: implement and use full_writev? */
296 return writev(1, io, (cur_io - io)) >= 0; 296 return writev(1, io, (cur_io - io)) >= 0;
297} 297}
298#endif 298#endif
diff --git a/coreutils/tr.c b/coreutils/tr.c
index 95f79b269..a28ab465e 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -182,7 +182,7 @@ int tr_main(int argc, char **argv)
182 ssize_t read_chars = 0; 182 ssize_t read_chars = 0;
183 size_t in_index = 0, out_index = 0; 183 size_t in_index = 0, out_index = 0;
184 unsigned last = UCHAR_MAX + 1; /* not equal to any char */ 184 unsigned last = UCHAR_MAX + 1; /* not equal to any char */
185 unsigned char coded, c; 185 unsigned char coded, c;
186 unsigned char *output = xmalloc(BUFSIZ); 186 unsigned char *output = xmalloc(BUFSIZ);
187 char *vector = xzalloc((ASCII+1) * 3); 187 char *vector = xzalloc((ASCII+1) * 3);
188 char *invec = vector + (ASCII+1); 188 char *invec = vector + (ASCII+1);
diff --git a/e2fsprogs/old_e2fsprogs/blkid/dev.c b/e2fsprogs/old_e2fsprogs/blkid/dev.c
index d86cc48d1..f6503f179 100644
--- a/e2fsprogs/old_e2fsprogs/blkid/dev.c
+++ b/e2fsprogs/old_e2fsprogs/blkid/dev.c
@@ -161,7 +161,7 @@ void usage(char *prog)
161int main(int argc, char **argv) 161int main(int argc, char **argv)
162{ 162{
163 blkid_dev_iterate iter; 163 blkid_dev_iterate iter;
164 blkid_cache cache = NULL; 164 blkid_cache cache = NULL;
165 blkid_dev dev; 165 blkid_dev dev;
166 int c, ret; 166 int c, ret;
167 char *tmp; 167 char *tmp;
diff --git a/e2fsprogs/old_e2fsprogs/blkid/tag.c b/e2fsprogs/old_e2fsprogs/blkid/tag.c
index 9e862a50a..006a393fa 100644
--- a/e2fsprogs/old_e2fsprogs/blkid/tag.c
+++ b/e2fsprogs/old_e2fsprogs/blkid/tag.c
@@ -364,7 +364,7 @@ void usage(char *prog)
364int main(int argc, char **argv) 364int main(int argc, char **argv)
365{ 365{
366 blkid_tag_iterate iter; 366 blkid_tag_iterate iter;
367 blkid_cache cache = NULL; 367 blkid_cache cache = NULL;
368 blkid_dev dev; 368 blkid_dev dev;
369 int c, ret, found; 369 int c, ret, found;
370 int flags = BLKID_DEV_FIND; 370 int flags = BLKID_DEV_FIND;
diff --git a/editors/sed_summary.htm b/editors/sed_summary.htm
index 4ac9b16f6..decf69b27 100644
--- a/editors/sed_summary.htm
+++ b/editors/sed_summary.htm
@@ -120,7 +120,7 @@ instead of resuming at the top of the script.</p></dd>
120 120
121<dt><b>N</b> [<em>address1</em>[,<em>address2</em>]]<b>N</b></dt> 121<dt><b>N</b> [<em>address1</em>[,<em>address2</em>]]<b>N</b></dt>
122<dd>Append next input line to contents of pattern space; the new line is 122<dd>Append next input line to contents of pattern space; the new line is
123separated from the previous contents of the pattern space by a newline. 123separated from the previous contents of the pattern space by a newline.
124(This command is designed to allow pattern matches across two 124(This command is designed to allow pattern matches across two
125lines. Using \n to match the embedded newline, you can match 125lines. Using \n to match the embedded newline, you can match
126patterns across multiple lines.)</p></dd> 126patterns across multiple lines.)</p></dd>
diff --git a/examples/bootfloppy/bootfloppy.txt b/examples/bootfloppy/bootfloppy.txt
index 6866b724f..9e2cbe2bc 100644
--- a/examples/bootfloppy/bootfloppy.txt
+++ b/examples/bootfloppy/bootfloppy.txt
@@ -76,7 +76,7 @@ The following steps will create a root file system.
76 76
77 - Make device files in /dev: 77 - Make device files in /dev:
78 78
79 This can be done by running the 'mkdevs.sh' script. If you want the gory 79 This can be done by running the 'mkdevs.sh' script. If you want the gory
80 details, you can read the script. 80 details, you can read the script.
81 81
82 - Make necessary files in /etc: 82 - Make necessary files in /etc:
diff --git a/examples/devfsd.conf b/examples/devfsd.conf
index e90e7102b..10f1c8788 100644
--- a/examples/devfsd.conf
+++ b/examples/devfsd.conf
@@ -78,7 +78,7 @@ REGISTER ^radio0$ EXECUTE /bin/ln -sf radio0 radio
78UNREGISTER ^radio0$ EXECUTE /bin/rm -f radio 78UNREGISTER ^radio0$ EXECUTE /bin/rm -f radio
79 79
80# ALSA stuff 80# ALSA stuff
81#LOOKUP snd MODLOAD ACTION snd 81#LOOKUP snd MODLOAD ACTION snd
82 82
83# Uncomment this to let PAM manage devfs 83# Uncomment this to let PAM manage devfs
84# Not supported by busybox 84# Not supported by busybox
diff --git a/examples/udhcp/udhcpd.conf b/examples/udhcp/udhcpd.conf
index 34e47f788..763a1217b 100644
--- a/examples/udhcp/udhcpd.conf
+++ b/examples/udhcp/udhcpd.conf
@@ -2,7 +2,7 @@
2 2
3# The start and end of the IP lease block 3# The start and end of the IP lease block
4 4
5start 192.168.0.20 #default: 192.168.0.20 5start 192.168.0.20 #default: 192.168.0.20
6end 192.168.0.254 #default: 192.168.0.254 6end 192.168.0.254 #default: 192.168.0.254
7 7
8 8
@@ -67,7 +67,7 @@ interface eth0 #default: eth0
67 67
68#notify_file #default: (no script) 68#notify_file #default: (no script)
69 69
70#notify_file dumpleases # <--- useful for debugging 70#notify_file dumpleases # <--- useful for debugging
71 71
72# The following are bootp specific options, setable by udhcpd. 72# The following are bootp specific options, setable by udhcpd.
73 73
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a0f190fd4..69768da30 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -136,7 +136,7 @@ static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
136#define command_ps (S.command_ps ) 136#define command_ps (S.command_ps )
137#define cmdedit_prompt (S.cmdedit_prompt ) 137#define cmdedit_prompt (S.cmdedit_prompt )
138#define num_ok_lines (S.num_ok_lines ) 138#define num_ok_lines (S.num_ok_lines )
139#define user_buf (S.user_buf ) 139#define user_buf (S.user_buf )
140#define home_pwd_buf (S.home_pwd_buf ) 140#define home_pwd_buf (S.home_pwd_buf )
141#define matches (S.matches ) 141#define matches (S.matches )
142#define num_matches (S.num_matches ) 142#define num_matches (S.num_matches )
diff --git a/networking/Config.in b/networking/Config.in
index b50aacf9f..5a766046a 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -549,6 +549,19 @@ config NAMEIF
549 # Comment 549 # Comment
550 new_interface_name XX:XX:XX:XX:XX:XX 550 new_interface_name XX:XX:XX:XX:XX:XX
551 551
552config FEATURE_NAMEIF_EXTENDED
553 bool "Extended nameif"
554 default n
555 depends on NAMEIF
556 help
557 This extends the nameif syntax to support the bus_info and driver
558 checks. The syntax is compatible to the normal nameif.
559 File format:
560 new_interface_name driver=asix bus=usb-0000:00:08.2-3
561 new_interface_name bus=usb-0000:00:08.2-3 00:80:C8:38:91:B5
562 new_interface_name mac=00:80:C8:38:91:B5
563 new_interface_name 00:80:C8:38:91:B5
564
552config NC 565config NC
553 bool "nc" 566 bool "nc"
554 default n 567 default n
diff --git a/networking/nameif.c b/networking/nameif.c
index a951970c2..66376a500 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -13,7 +13,7 @@
13#include <syslog.h> 13#include <syslog.h>
14#include <net/if.h> 14#include <net/if.h>
15#include <netinet/ether.h> 15#include <netinet/ether.h>
16 16#include <linux/sockios.h>
17 17
18/* Older versions of net/if.h do not appear to define IF_NAMESIZE. */ 18/* Older versions of net/if.h do not appear to define IF_NAMESIZE. */
19#ifndef IF_NAMESIZE 19#ifndef IF_NAMESIZE
@@ -34,138 +34,214 @@
34#define ifr_newname ifr_ifru.ifru_slave 34#define ifr_newname ifr_ifru.ifru_slave
35#endif 35#endif
36 36
37typedef struct mactable_s { 37typedef struct ethtable_s {
38 struct mactable_s *next; 38 struct ethtable_s *next;
39 struct mactable_s *prev; 39 struct ethtable_s *prev;
40 char *ifname; 40 char *ifname;
41 struct ether_addr *mac; 41 struct ether_addr *mac;
42} mactable_t; 42#if ENABLE_FEATURE_NAMEIF_EXTENDED
43 char *bus_info;
44 char *driver;
45#endif
46} ethtable_t;
47
48#if ENABLE_FEATURE_NAMEIF_EXTENDED
49/* Cut'n'paste from ethtool.h */
50#define ETHTOOL_BUSINFO_LEN 32
51/* these strings are set to whatever the driver author decides... */
52struct ethtool_drvinfo {
53 __u32 cmd;
54 char driver[32]; /* driver short name, "tulip", "eepro100" */
55 char version[32]; /* driver version string */
56 char fw_version[32]; /* firmware version string, if applicable */
57 char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
58 /* For PCI devices, use pci_dev->slot_name. */
59 char reserved1[32];
60 char reserved2[16];
61 __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
62 __u32 testinfo_len;
63 __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
64 __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
65};
66#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
67#endif
68
43 69
44/* Check ascii str_macaddr, convert and copy to *mac */ 70static void nameif_parse_selector(ethtable_t *ch, char *selector)
45static struct ether_addr *cc_macaddr(const char *str_macaddr)
46{ 71{
47 struct ether_addr *lmac, *mac; 72 struct ether_addr *lmac;
73#if ENABLE_FEATURE_NAMEIF_EXTENDED
74 int found_selector = 0;
48 75
49 lmac = ether_aton(str_macaddr); 76 while (*selector) {
50 if (lmac == NULL) 77 char *next;
51 bb_error_msg_and_die("cannot parse MAC %s", str_macaddr); 78#endif
52 mac = xmalloc(ETH_ALEN); 79 selector = skip_whitespace(selector);
53 memcpy(mac, lmac, ETH_ALEN); 80#if ENABLE_FEATURE_NAMEIF_EXTENDED
81 if (*selector == '\0')
82 break;
83 /* Search for the end .... */
84 next = skip_non_whitespace(selector);
85 if (*next)
86 *next++ = '\0';
87 /* Check for selectors, mac= is assumed */
88 if (strncmp(selector, "bus=", 4) == 0) {
89 ch->bus_info = xstrdup(selector + 4);
90 found_selector++;
91 } else if (strncmp(selector, "driver=", 7) == 0) {
92 ch->driver = xstrdup(selector + 7);
93 found_selector++;
94 } else {
95#endif
96 lmac = ether_aton(selector + (strncmp(selector, "mac=", 4) == 0 ? 4 : 0));
97 /* Check ascii selector, convert and copy to *mac */
98 if (lmac == NULL)
99 bb_error_msg_and_die("cannot parse %s", selector);
100 ch->mac = xmalloc(ETH_ALEN);
101 memcpy(ch->mac, lmac, ETH_ALEN);
102#if ENABLE_FEATURE_NAMEIF_EXTENDED
103 found_selector++;
104 };
105 selector = next;
106 }
107 if (found_selector == 0)
108 bb_error_msg_and_die("no selectors found for %s", ch->ifname);
109#endif
110}
54 111
55 return mac; 112static void prepend_new_eth_table(ethtable_t **clist, char *ifname, char *selector)
113{
114 ethtable_t *ch;
115 if (strlen(ifname) >= IF_NAMESIZE)
116 bb_error_msg_and_die("interface name '%s' too long", ifname);
117 ch = xzalloc(sizeof(*ch));
118 ch->ifname = ifname;
119 nameif_parse_selector(ch, selector);
120 ch->next = *clist;
121 if (*clist)
122 (*clist)->prev = ch;
123 *clist = ch;
56} 124}
57 125
58int nameif_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 126int nameif_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
59int nameif_main(int argc, char **argv) 127int nameif_main(int argc, char **argv)
60{ 128{
61 mactable_t *clist = NULL; 129 ethtable_t *clist = NULL;
62 FILE *ifh; 130 FILE *ifh;
63 const char *fname = "/etc/mactab"; 131 const char *fname = "/etc/mactab";
64 char *line; 132 char *line;
133 char *line_ptr;
134 int linenum;
65 int ctl_sk; 135 int ctl_sk;
66 int if_index = 1; 136 ethtable_t *ch;
67 mactable_t *ch;
68 137
69 if (1 & getopt32(argv, "sc:", &fname)) { 138 if (1 & getopt32(argv, "sc:", &fname)) {
70 openlog(applet_name, 0, LOG_LOCAL0); 139 openlog(applet_name, 0, LOG_LOCAL0);
71 logmode = LOGMODE_SYSLOG; 140 logmode = LOGMODE_SYSLOG;
72 } 141 }
142 argc -= optind;
143 argv += optind;
73 144
74 if ((argc - optind) & 1) 145 if (argc & 1)
75 bb_show_usage(); 146 bb_show_usage();
76 147
77 if (optind < argc) { 148 if (argc) {
78 char **a = argv + optind; 149 while (*argv) {
79 150 char *ifname = xstrdup(*argv++);
80 while (*a) { 151 prepend_new_eth_table(&clist, ifname, *argv++);
81 if (strlen(*a) > IF_NAMESIZE)
82 bb_error_msg_and_die("interface name '%s' "
83 "too long", *a);
84 ch = xzalloc(sizeof(mactable_t));
85 ch->ifname = xstrdup(*a++);
86 ch->mac = cc_macaddr(*a++);
87 if (clist)
88 clist->prev = ch;
89 ch->next = clist;
90 clist = ch;
91 } 152 }
92 } else { 153 } else {
93 ifh = xfopen(fname, "r"); 154 ifh = xfopen(fname, "r");
94
95 while ((line = xmalloc_fgets(ifh)) != NULL) { 155 while ((line = xmalloc_fgets(ifh)) != NULL) {
96 char *line_ptr; 156 char *next;
97 size_t name_length;
98 157
99 line_ptr = line + strspn(line, " \t"); 158 line_ptr = skip_whitespace(line);
100 if ((line_ptr[0] == '#') || (line_ptr[0] == '\n')) { 159 if ((line_ptr[0] == '#') || (line_ptr[0] == '\n')) {
101 free(line); 160 free(line);
102 continue; 161 continue;
103 } 162 }
104 name_length = strcspn(line_ptr, " \t"); 163 next = skip_non_whitespace(line_ptr);
105 ch = xzalloc(sizeof(mactable_t)); 164 if (*next)
106 ch->ifname = xstrndup(line_ptr, name_length); 165 *next++ = '\0';
107 if (name_length > IF_NAMESIZE) 166 prepend_new_eth_table(&clist, line_ptr, next);
108 bb_error_msg_and_die("interface name '%s' "
109 "too long", ch->ifname);
110 line_ptr += name_length;
111 line_ptr += strspn(line_ptr, " \t");
112 name_length = strspn(line_ptr, "0123456789ABCDEFabcdef:");
113 line_ptr[name_length] = '\0';
114 ch->mac = cc_macaddr(line_ptr);
115 if (clist)
116 clist->prev = ch;
117 ch->next = clist;
118 clist = ch;
119 free(line); 167 free(line);
120 } 168 }
121 fclose(ifh); 169 fclose(ifh);
122 } 170 }
123 171
124 ctl_sk = xsocket(PF_INET, SOCK_DGRAM, 0); 172 ctl_sk = xsocket(PF_INET, SOCK_DGRAM, 0);
173 ifh = xfopen("/proc/net/dev", "r");
125 174
175 linenum = 0;
126 while (clist) { 176 while (clist) {
127 struct ifreq ifr; 177 struct ifreq ifr;
178#if ENABLE_FEATURE_NAMEIF_EXTENDED
179 struct ethtool_drvinfo drvinfo;
180#endif
128 181
129 memset(&ifr, 0, sizeof(struct ifreq)); 182 line = xmalloc_fgets(ifh);
130 if_index++; 183 if (line == NULL)
131 ifr.ifr_ifindex = if_index; 184 break; /* Seems like we're done */
132 185 if (linenum++ < 2 )
133 /* Get ifname by index or die */ 186 goto next_line; /* Skip the first two lines */
134 if (ioctl(ctl_sk, SIOCGIFNAME, &ifr))
135 break;
136
137 /* Has this device hwaddr? */
138 if (ioctl(ctl_sk, SIOCGIFHWADDR, &ifr))
139 continue;
140 187
141 /* Search for mac like in ifr.ifr_hwaddr.sa_data */ 188 /* Find the current interface name and copy it to ifr.ifr_name */
142 for (ch = clist; ch; ch = ch->next) 189 line_ptr = skip_whitespace(line);
143 if (!memcmp(ch->mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN)) 190 *skip_non_whitespace(line_ptr) = '\0';
144 break;
145 191
146 /* Nothing found for current ifr.ifr_hwaddr.sa_data */ 192 memset(&ifr, 0, sizeof(struct ifreq));
147 if (ch == NULL) 193 strncpy(ifr.ifr_name, line_ptr, sizeof(ifr.ifr_name));
148 continue; 194
195#if ENABLE_FEATURE_NAMEIF_EXTENDED
196 /* Check for driver etc. */
197 memset(&drvinfo, 0, sizeof(struct ethtool_drvinfo));
198 drvinfo.cmd = ETHTOOL_GDRVINFO;
199 ifr.ifr_data = (caddr_t) &drvinfo;
200 /* Get driver and businfo first, so we have it in drvinfo */
201 ioctl(ctl_sk, SIOCETHTOOL, &ifr);
202#endif
203 ioctl(ctl_sk, SIOCGIFHWADDR, &ifr);
149 204
150 strcpy(ifr.ifr_newname, ch->ifname); 205 /* Search the list for a matching device */
151 ioctl_or_perror_and_die(ctl_sk, SIOCSIFNAME, &ifr, 206 for (ch = clist; ch; ch = ch->next) {
207#if ENABLE_FEATURE_NAMEIF_EXTENDED
208 if (ch->bus_info && strcmp(ch->bus_info, drvinfo.bus_info) != 0)
209 continue;
210 if (ch->driver && strcmp(ch->driver, drvinfo.driver) != 0)
211 continue;
212#endif
213 if (ch->mac && memcmp(ch->mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN) != 0)
214 continue;
215 /* if we came here, all selectors have matched */
216 goto found;
217 }
218 /* Nothing found for current interface */
219 goto next_line;
220 found:
221 if (strcmp(ifr.ifr_name, ch->ifname) != 0) {
222 strcpy(ifr.ifr_newname, ch->ifname);
223 ioctl_or_perror_and_die(ctl_sk, SIOCSIFNAME, &ifr,
152 "cannot change ifname %s to %s", 224 "cannot change ifname %s to %s",
153 ifr.ifr_name, ch->ifname); 225 ifr.ifr_name, ch->ifname);
154 226 }
155 /* Remove list entry of renamed interface */ 227 /* Remove list entry of renamed interface */
156 if (ch->prev != NULL) { 228 if (ch->prev != NULL)
157 (ch->prev)->next = ch->next; 229 ch->prev->next = ch->next;
158 } else { 230 else
159 clist = ch->next; 231 clist = ch->next;
160 }
161 if (ch->next != NULL) 232 if (ch->next != NULL)
162 (ch->next)->prev = ch->prev; 233 ch->next->prev = ch->prev;
163 if (ENABLE_FEATURE_CLEAN_UP) { 234 if (ENABLE_FEATURE_CLEAN_UP) {
164 free(ch->ifname); 235 free(ch->ifname);
165 free(ch->mac); 236 free(ch->mac);
166 free(ch); 237 free(ch);
167 } 238 }
239 next_line:
240 free(line);
168 } 241 }
242 if (ENABLE_FEATURE_CLEAN_UP) {
243 fclose(ifh);
244 };
169 245
170 return 0; 246 return 0;
171} 247}
diff --git a/util-linux/more.c b/util-linux/more.c
index ee559b102..2d7f3a9e4 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -165,7 +165,7 @@ int more_main(int argc, char **argv)
165 if (c == '\t') { 165 if (c == '\t') {
166 spaces = CONVERTED_TAB_SIZE - 1; 166 spaces = CONVERTED_TAB_SIZE - 1;
167 c = ' '; 167 c = ' ';
168 } 168 }
169 169
170 /* 170 /*
171 * There are two input streams to worry about here: 171 * There are two input streams to worry about here: