diff options
author | John Beppu <beppu@lbox.org> | 2000-02-11 12:52:55 +0000 |
---|---|---|
committer | John Beppu <beppu@lbox.org> | 2000-02-11 12:52:55 +0000 |
commit | 5e1b2ca1161cba481ccf4873427389f59dbc23e0 (patch) | |
tree | be383c16e82d92c627a2080a5e711830cfc4d046 /fsck_minix.c | |
parent | fa376f80348b4241124c8e4c727bcb57181e50d1 (diff) | |
download | busybox-w32-5e1b2ca1161cba481ccf4873427389f59dbc23e0.tar.gz busybox-w32-5e1b2ca1161cba481ccf4873427389f59dbc23e0.tar.bz2 busybox-w32-5e1b2ca1161cba481ccf4873427389f59dbc23e0.zip |
+ memory allocation/deallocation is less tolerant of evil.
Diffstat (limited to 'fsck_minix.c')
-rw-r--r-- | fsck_minix.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/fsck_minix.c b/fsck_minix.c index 9da79748f..cfa973ecf 100644 --- a/fsck_minix.c +++ b/fsck_minix.c | |||
@@ -146,7 +146,7 @@ static int termios_set = 0; | |||
146 | #define MAX_DEPTH 32 | 146 | #define MAX_DEPTH 32 |
147 | static int name_depth = 0; | 147 | static int name_depth = 0; |
148 | // static char name_list[MAX_DEPTH][PATH_MAX + 1]; | 148 | // static char name_list[MAX_DEPTH][PATH_MAX + 1]; |
149 | static char **name_list; | 149 | static char **name_list = NULL; |
150 | 150 | ||
151 | static char *inode_buffer = NULL; | 151 | static char *inode_buffer = NULL; |
152 | 152 | ||
@@ -1248,14 +1248,33 @@ static void alloc_name_list(void) | |||
1248 | int i; | 1248 | int i; |
1249 | 1249 | ||
1250 | name_list = malloc(sizeof(char *) * MAX_DEPTH); | 1250 | name_list = malloc(sizeof(char *) * MAX_DEPTH); |
1251 | if (!name_list) { | ||
1252 | fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno)); | ||
1253 | exit(1); | ||
1254 | } | ||
1251 | for (i = 0; i < MAX_DEPTH; i++) { | 1255 | for (i = 0; i < MAX_DEPTH; i++) { |
1252 | name_list[i] = malloc(sizeof(char) * PATH_MAX + 1); | 1256 | name_list[i] = malloc(sizeof(char) * PATH_MAX + 1); |
1257 | if (!name_list[i]) { | ||
1258 | fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno)); | ||
1259 | exit(1); | ||
1260 | } | ||
1253 | } | 1261 | } |
1254 | } | 1262 | } |
1255 | 1263 | ||
1264 | /* execute this atexit() to deallocate name_list[] */ | ||
1265 | /* piptigger was here */ | ||
1256 | static void free_name_list(void) | 1266 | static void free_name_list(void) |
1257 | { | 1267 | { |
1258 | if (name_list) free(name_list); | 1268 | int i; |
1269 | |||
1270 | if (name_list) { | ||
1271 | for (i = 0; i < MAX_DEPTH; i++) { | ||
1272 | if (name_list[i]) { | ||
1273 | free(name_list[i]); | ||
1274 | } | ||
1275 | } | ||
1276 | free(name_list); | ||
1277 | } | ||
1259 | } | 1278 | } |
1260 | 1279 | ||
1261 | extern int fsck_minix_main(int argc, char **argv) | 1280 | extern int fsck_minix_main(int argc, char **argv) |