diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-09 19:44:08 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-09 19:44:08 +0000 |
commit | 96c45b0e0bda5bf47c03682c8fcbeae7ade89386 (patch) | |
tree | 5c85d37b5e2dd9a28d547416638622f63e792e52 | |
parent | 5606b1c4f36d6f4f467f85a417183a70bc00fe1d (diff) | |
download | busybox-w32-96c45b0e0bda5bf47c03682c8fcbeae7ade89386.tar.gz busybox-w32-96c45b0e0bda5bf47c03682c8fcbeae7ade89386.tar.bz2 busybox-w32-96c45b0e0bda5bf47c03682c8fcbeae7ade89386.zip |
libbb/mtab: fix xrealloc_vector fallout
-rw-r--r-- | libbb/mtab.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libbb/mtab.c b/libbb/mtab.c index 2c171322a..586a66196 100644 --- a/libbb/mtab.c +++ b/libbb/mtab.c | |||
@@ -13,8 +13,8 @@ | |||
13 | #if ENABLE_FEATURE_MTAB_SUPPORT | 13 | #if ENABLE_FEATURE_MTAB_SUPPORT |
14 | void FAST_FUNC erase_mtab(const char *name) | 14 | void FAST_FUNC erase_mtab(const char *name) |
15 | { | 15 | { |
16 | struct mntent *entries = NULL; | 16 | struct mntent *entries; |
17 | int i, count = 0; | 17 | int i, count; |
18 | FILE *mountTable; | 18 | FILE *mountTable; |
19 | struct mntent *m; | 19 | struct mntent *m; |
20 | 20 | ||
@@ -26,18 +26,21 @@ void FAST_FUNC erase_mtab(const char *name) | |||
26 | return; | 26 | return; |
27 | } | 27 | } |
28 | 28 | ||
29 | entries = NULL; | ||
30 | count = 0; | ||
29 | while ((m = getmntent(mountTable)) != 0) { | 31 | while ((m = getmntent(mountTable)) != 0) { |
30 | entries = xrealloc(entries, 3, count); | 32 | entries = xrealloc_vector(entries, 3, count); |
31 | entries[count].mnt_fsname = xstrdup(m->mnt_fsname); | 33 | entries[count].mnt_fsname = xstrdup(m->mnt_fsname); |
32 | entries[count].mnt_dir = xstrdup(m->mnt_dir); | 34 | entries[count].mnt_dir = xstrdup(m->mnt_dir); |
33 | entries[count].mnt_type = xstrdup(m->mnt_type); | 35 | entries[count].mnt_type = xstrdup(m->mnt_type); |
34 | entries[count].mnt_opts = xstrdup(m->mnt_opts); | 36 | entries[count].mnt_opts = xstrdup(m->mnt_opts); |
35 | entries[count].mnt_freq = m->mnt_freq; | 37 | entries[count].mnt_freq = m->mnt_freq; |
36 | entries[count].mnt_passno = m->mnt_passno; | 38 | entries[count].mnt_passno = m->mnt_passno; |
37 | i = count++; | 39 | count++; |
38 | } | 40 | } |
39 | endmntent(mountTable); | 41 | endmntent(mountTable); |
40 | 42 | ||
43 | //TODO: make update atomic | ||
41 | mountTable = setmntent(bb_path_mtab_file, "w"); | 44 | mountTable = setmntent(bb_path_mtab_file, "w"); |
42 | if (mountTable) { | 45 | if (mountTable) { |
43 | for (i = 0; i < count; i++) { | 46 | for (i = 0; i < count; i++) { |