diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | editors/sed.c | 2 | ||||
-rw-r--r-- | miscutils/hdparm.c | 4 | ||||
-rw-r--r-- | networking/ifupdown.c | 72 | ||||
-rw-r--r-- | procps/ps.c | 4 | ||||
-rw-r--r-- | shell/hush.c | 2 |
6 files changed, 44 insertions, 42 deletions
@@ -1,6 +1,6 @@ | |||
1 | VERSION = 1 | 1 | VERSION = 1 |
2 | PATCHLEVEL = 5 | 2 | PATCHLEVEL = 5 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 1 |
4 | EXTRAVERSION = | 4 | EXTRAVERSION = |
5 | NAME = Unnamed | 5 | NAME = Unnamed |
6 | 6 | ||
diff --git a/editors/sed.c b/editors/sed.c index f7f22f750..8500989ba 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -481,7 +481,7 @@ static void add_cmd(const char *cmdstr) | |||
481 | if (bbg.add_cmd_line) { | 481 | if (bbg.add_cmd_line) { |
482 | char *tp = xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr); | 482 | char *tp = xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr); |
483 | free(bbg.add_cmd_line); | 483 | free(bbg.add_cmd_line); |
484 | bbg.add_cmd_line = tp; | 484 | cmdstr = bbg.add_cmd_line = tp; |
485 | } | 485 | } |
486 | 486 | ||
487 | /* If this line ends with backslash, request next line. */ | 487 | /* If this line ends with backslash, request next line. */ |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 0138eed92..b5297775a 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -1569,9 +1569,9 @@ static void process_dev(char *devname) | |||
1569 | if (set_mult) { | 1569 | if (set_mult) { |
1570 | print_flag(get_mult, "multcount", mult); | 1570 | print_flag(get_mult, "multcount", mult); |
1571 | #ifdef HDIO_DRIVE_CMD | 1571 | #ifdef HDIO_DRIVE_CMD |
1572 | bb_ioctl(fd, HDIO_SET_MULTCOUNT, &mult, "HDIO_SET_MULTCOUNT"); | 1572 | bb_ioctl(fd, HDIO_SET_MULTCOUNT, (void *)mult, "HDIO_SET_MULTCOUNT"); |
1573 | #else | 1573 | #else |
1574 | force_operation |= (!bb_ioctl(fd, HDIO_SET_MULTCOUNT, &mult, "HDIO_SET_MULTCOUNT")); | 1574 | force_operation |= (!bb_ioctl(fd, HDIO_SET_MULTCOUNT, (void *)mult, "HDIO_SET_MULTCOUNT")); |
1575 | #endif | 1575 | #endif |
1576 | } | 1576 | } |
1577 | if (set_readonly) { | 1577 | if (set_readonly) { |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 887c2eea5..74646c6f5 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1083,15 +1083,32 @@ static llist_t *find_iface_state(llist_t *state_list, const char *iface) | |||
1083 | return NULL; | 1083 | return NULL; |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | /* read the previous state from the state file */ | ||
1087 | static llist_t *read_iface_state(void) { | ||
1088 | llist_t *state_list = NULL; | ||
1089 | FILE *state_fp; | ||
1090 | state_fp = fopen("/var/run/ifstate", "r"); | ||
1091 | if (state_fp) { | ||
1092 | char *start, *end_ptr; | ||
1093 | while ((start = xmalloc_fgets(state_fp)) != NULL) { | ||
1094 | /* We should only need to check for a single character */ | ||
1095 | end_ptr = start + strcspn(start, " \t\n"); | ||
1096 | *end_ptr = '\0'; | ||
1097 | llist_add_to(&state_list, start); | ||
1098 | } | ||
1099 | fclose(state_fp); | ||
1100 | } | ||
1101 | return state_list; | ||
1102 | } | ||
1103 | |||
1104 | |||
1086 | int ifupdown_main(int argc, char **argv); | 1105 | int ifupdown_main(int argc, char **argv); |
1087 | int ifupdown_main(int argc, char **argv) | 1106 | int ifupdown_main(int argc, char **argv) |
1088 | { | 1107 | { |
1089 | int (*cmds)(struct interface_defn_t *) = NULL; | 1108 | int (*cmds)(struct interface_defn_t *) = NULL; |
1090 | struct interfaces_file_t *defn; | 1109 | struct interfaces_file_t *defn; |
1091 | llist_t *state_list = NULL; | ||
1092 | llist_t *target_list = NULL; | 1110 | llist_t *target_list = NULL; |
1093 | const char *interfaces = "/etc/network/interfaces"; | 1111 | const char *interfaces = "/etc/network/interfaces"; |
1094 | FILE *state_fp; | ||
1095 | bool any_failures = 0; | 1112 | bool any_failures = 0; |
1096 | 1113 | ||
1097 | cmds = iface_down; | 1114 | cmds = iface_down; |
@@ -1118,32 +1135,9 @@ int ifupdown_main(int argc, char **argv) | |||
1118 | startup_PATH = getenv("PATH"); | 1135 | startup_PATH = getenv("PATH"); |
1119 | if (!startup_PATH) startup_PATH = ""; | 1136 | if (!startup_PATH) startup_PATH = ""; |
1120 | 1137 | ||
1121 | /* Read the previous state from the state file */ | ||
1122 | state_fp = fopen("/var/run/ifstate", "r"); | ||
1123 | if (state_fp) { | ||
1124 | char *start, *end_ptr; | ||
1125 | while ((start = xmalloc_fgets(state_fp)) != NULL) { | ||
1126 | /* We should only need to check for a single character */ | ||
1127 | end_ptr = start + strcspn(start, " \t\n"); | ||
1128 | *end_ptr = '\0'; | ||
1129 | llist_add_to(&state_list, start); | ||
1130 | } | ||
1131 | fclose(state_fp); | ||
1132 | } | ||
1133 | |||
1134 | /* Create a list of interfaces to work on */ | 1138 | /* Create a list of interfaces to work on */ |
1135 | if (DO_ALL) { | 1139 | if (DO_ALL) { |
1136 | if (cmds == iface_up) { | 1140 | target_list = defn->autointerfaces; |
1137 | target_list = defn->autointerfaces; | ||
1138 | } else { | ||
1139 | /* iface_down */ | ||
1140 | const llist_t *list = state_list; | ||
1141 | while (list) { | ||
1142 | llist_add_to_end(&target_list, xstrdup(list->data)); | ||
1143 | list = list->link; | ||
1144 | } | ||
1145 | target_list = defn->autointerfaces; | ||
1146 | } | ||
1147 | } else { | 1141 | } else { |
1148 | llist_add_to_end(&target_list, argv[optind]); | 1142 | llist_add_to_end(&target_list, argv[optind]); |
1149 | } | 1143 | } |
@@ -1170,6 +1164,7 @@ int ifupdown_main(int argc, char **argv) | |||
1170 | } | 1164 | } |
1171 | 1165 | ||
1172 | if (!FORCE) { | 1166 | if (!FORCE) { |
1167 | llist_t *state_list = read_iface_state(); | ||
1173 | const llist_t *iface_state = find_iface_state(state_list, iface); | 1168 | const llist_t *iface_state = find_iface_state(state_list, iface); |
1174 | 1169 | ||
1175 | if (cmds == iface_up) { | 1170 | if (cmds == iface_up) { |
@@ -1185,6 +1180,7 @@ int ifupdown_main(int argc, char **argv) | |||
1185 | continue; | 1180 | continue; |
1186 | } | 1181 | } |
1187 | } | 1182 | } |
1183 | llist_free(state_list, free); | ||
1188 | } | 1184 | } |
1189 | 1185 | ||
1190 | #if ENABLE_FEATURE_IFUPDOWN_MAPPING | 1186 | #if ENABLE_FEATURE_IFUPDOWN_MAPPING |
@@ -1239,6 +1235,8 @@ int ifupdown_main(int argc, char **argv) | |||
1239 | bb_error_msg("ignoring unknown interface %s", liface); | 1235 | bb_error_msg("ignoring unknown interface %s", liface); |
1240 | any_failures = 1; | 1236 | any_failures = 1; |
1241 | } else { | 1237 | } else { |
1238 | /* update the state file */ | ||
1239 | llist_t *state_list = read_iface_state(); | ||
1242 | llist_t *iface_state = find_iface_state(state_list, iface); | 1240 | llist_t *iface_state = find_iface_state(state_list, iface); |
1243 | 1241 | ||
1244 | if (cmds == iface_up) { | 1242 | if (cmds == iface_up) { |
@@ -1254,19 +1252,21 @@ int ifupdown_main(int argc, char **argv) | |||
1254 | llist_unlink(&state_list, iface_state); | 1252 | llist_unlink(&state_list, iface_state); |
1255 | free(llist_pop(&iface_state)); | 1253 | free(llist_pop(&iface_state)); |
1256 | } | 1254 | } |
1257 | } | ||
1258 | } | ||
1259 | 1255 | ||
1260 | /* Actually write the new state */ | 1256 | /* Actually write the new state */ |
1261 | if (!NO_ACT) { | 1257 | if (!NO_ACT) { |
1262 | state_fp = xfopen("/var/run/ifstate", "w"); | 1258 | FILE *state_fp = xfopen("/var/run/ifstate", "w"); |
1263 | while (state_list) { | 1259 | llist_t *state = state_list; |
1264 | if (state_list->data) { | 1260 | while (state) { |
1265 | fprintf(state_fp, "%s\n", state_list->data); | 1261 | if (state->data) { |
1262 | fprintf(state_fp, "%s\n", state->data); | ||
1263 | } | ||
1264 | state = state->link; | ||
1265 | } | ||
1266 | fclose(state_fp); | ||
1266 | } | 1267 | } |
1267 | state_list = state_list->link; | 1268 | llist_free(state_list, free); |
1268 | } | 1269 | } |
1269 | fclose(state_fp); | ||
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | return any_failures; | 1272 | return any_failures; |
diff --git a/procps/ps.c b/procps/ps.c index c1cb64397..2be0b3605 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -262,7 +262,9 @@ int ps_main(int argc, char **argv) | |||
262 | parse_o(default_o); | 262 | parse_o(default_o); |
263 | post_process(); | 263 | post_process(); |
264 | 264 | ||
265 | terminal_width = INT_MAX; | 265 | /* Was INT_MAX, but some libc's go belly up with printf("%.*s") |
266 | * and such large widths */ | ||
267 | terminal_width = 30000; | ||
266 | if (isatty(1)) { | 268 | if (isatty(1)) { |
267 | get_terminal_width_height(1, &terminal_width, NULL); | 269 | get_terminal_width_height(1, &terminal_width, NULL); |
268 | terminal_width--; | 270 | terminal_width--; |
diff --git a/shell/hush.c b/shell/hush.c index 7658aebed..cc0cb69bd 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1840,7 +1840,7 @@ static int set_local_var(const char *s, int flg_export) | |||
1840 | result = -1; | 1840 | result = -1; |
1841 | } else { | 1841 | } else { |
1842 | cur->name = strdup(name); | 1842 | cur->name = strdup(name); |
1843 | if (cur->name) { | 1843 | if (!cur->name) { |
1844 | free(cur); | 1844 | free(cur); |
1845 | result = -1; | 1845 | result = -1; |
1846 | } else { | 1846 | } else { |