diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-02 10:48:06 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-02 10:48:06 +0000 |
commit | 04158e04591efea20f34c8dc83002e19056a5590 (patch) | |
tree | 1deace5081207ddefa831e024e5914a11a8aaeeb | |
parent | 512c8ae0537ad2ffcb70db03ca50b532781ae799 (diff) | |
download | busybox-w32-04158e04591efea20f34c8dc83002e19056a5590.tar.gz busybox-w32-04158e04591efea20f34c8dc83002e19056a5590.tar.bz2 busybox-w32-04158e04591efea20f34c8dc83002e19056a5590.zip |
udhcpd: add code which rejects lease files with suspicious or old timestamp.
*: s/time(0)/time(NULL)/g
-rw-r--r-- | e2fsprogs/old_e2fsprogs/blkid/devname.c | 4 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/blkid/probe.c | 4 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/e2fsck.c | 28 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c | 4 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c | 4 | ||||
-rw-r--r-- | networking/httpd.c | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.c | 4 | ||||
-rw-r--r-- | networking/udhcp/files.c | 32 | ||||
-rw-r--r-- | runit/sv.c | 4 | ||||
-rw-r--r-- | util-linux/rtcwake.c | 2 |
11 files changed, 46 insertions, 44 deletions
diff --git a/e2fsprogs/old_e2fsprogs/blkid/devname.c b/e2fsprogs/old_e2fsprogs/blkid/devname.c index 5b9e48f13..348e5d42e 100644 --- a/e2fsprogs/old_e2fsprogs/blkid/devname.c +++ b/e2fsprogs/old_e2fsprogs/blkid/devname.c | |||
@@ -273,7 +273,7 @@ int blkid_probe_all(blkid_cache cache) | |||
273 | return -BLKID_ERR_PARAM; | 273 | return -BLKID_ERR_PARAM; |
274 | 274 | ||
275 | if (cache->bic_flags & BLKID_BIC_FL_PROBED && | 275 | if (cache->bic_flags & BLKID_BIC_FL_PROBED && |
276 | time(0) - cache->bic_time < BLKID_PROBE_INTERVAL) | 276 | time(NULL) - cache->bic_time < BLKID_PROBE_INTERVAL) |
277 | return 0; | 277 | return 0; |
278 | 278 | ||
279 | blkid_read_cache(cache); | 279 | blkid_read_cache(cache); |
@@ -335,7 +335,7 @@ int blkid_probe_all(blkid_cache cache) | |||
335 | 335 | ||
336 | fclose(proc); | 336 | fclose(proc); |
337 | 337 | ||
338 | cache->bic_time = time(0); | 338 | cache->bic_time = time(NULL); |
339 | cache->bic_flags |= BLKID_BIC_FL_PROBED; | 339 | cache->bic_flags |= BLKID_BIC_FL_PROBED; |
340 | blkid_flush_cache(cache); | 340 | blkid_flush_cache(cache); |
341 | return 0; | 341 | return 0; |
diff --git a/e2fsprogs/old_e2fsprogs/blkid/probe.c b/e2fsprogs/old_e2fsprogs/blkid/probe.c index 48b240e98..1f7188e6d 100644 --- a/e2fsprogs/old_e2fsprogs/blkid/probe.c +++ b/e2fsprogs/old_e2fsprogs/blkid/probe.c | |||
@@ -562,7 +562,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) | |||
562 | if (!dev) | 562 | if (!dev) |
563 | return NULL; | 563 | return NULL; |
564 | 564 | ||
565 | now = time(0); | 565 | now = time(NULL); |
566 | diff = now - dev->bid_time; | 566 | diff = now - dev->bid_time; |
567 | 567 | ||
568 | if ((now < dev->bid_time) || | 568 | if ((now < dev->bid_time) || |
@@ -659,7 +659,7 @@ try_again: | |||
659 | found_type: | 659 | found_type: |
660 | if (dev && type) { | 660 | if (dev && type) { |
661 | dev->bid_devno = st.st_rdev; | 661 | dev->bid_devno = st.st_rdev; |
662 | dev->bid_time = time(0); | 662 | dev->bid_time = time(NULL); |
663 | dev->bid_flags |= BLKID_BID_FL_VERIFIED; | 663 | dev->bid_flags |= BLKID_BID_FL_VERIFIED; |
664 | cache->bic_flags |= BLKID_BIC_FL_CHANGED; | 664 | cache->bic_flags |= BLKID_BIC_FL_CHANGED; |
665 | 665 | ||
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index b927a9f65..6ade0db16 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c | |||
@@ -2270,7 +2270,7 @@ static void e2fsck_move_ext3_journal(e2fsck_t ctx) | |||
2270 | ext2fs_mark_super_dirty(fs); | 2270 | ext2fs_mark_super_dirty(fs); |
2271 | fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; | 2271 | fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; |
2272 | inode.i_links_count = 0; | 2272 | inode.i_links_count = 0; |
2273 | inode.i_dtime = time(0); | 2273 | inode.i_dtime = time(NULL); |
2274 | if ((retval = ext2fs_write_inode(fs, ino, &inode)) != 0) | 2274 | if ((retval = ext2fs_write_inode(fs, ino, &inode)) != 0) |
2275 | goto err_out; | 2275 | goto err_out; |
2276 | 2276 | ||
@@ -3381,7 +3381,7 @@ static void e2fsck_pass1(e2fsck_t ctx) | |||
3381 | */ | 3381 | */ |
3382 | if (!LINUX_S_ISDIR(inode->i_mode)) { | 3382 | if (!LINUX_S_ISDIR(inode->i_mode)) { |
3383 | if (fix_problem(ctx, PR_1_ROOT_NO_DIR, &pctx)) { | 3383 | if (fix_problem(ctx, PR_1_ROOT_NO_DIR, &pctx)) { |
3384 | inode->i_dtime = time(0); | 3384 | inode->i_dtime = time(NULL); |
3385 | inode->i_links_count = 0; | 3385 | inode->i_links_count = 0; |
3386 | ext2fs_icount_store(ctx->inode_link_info, | 3386 | ext2fs_icount_store(ctx->inode_link_info, |
3387 | ino, 0); | 3387 | ino, 0); |
@@ -3475,7 +3475,7 @@ static void e2fsck_pass1(e2fsck_t ctx) | |||
3475 | inode->i_dtime < ctx->fs->super->s_inodes_count) { | 3475 | inode->i_dtime < ctx->fs->super->s_inodes_count) { |
3476 | if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) { | 3476 | if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) { |
3477 | inode->i_dtime = inode->i_links_count ? | 3477 | inode->i_dtime = inode->i_links_count ? |
3478 | 0 : time(0); | 3478 | 0 : time(NULL); |
3479 | e2fsck_write_inode(ctx, ino, inode, | 3479 | e2fsck_write_inode(ctx, ino, inode, |
3480 | "pass1"); | 3480 | "pass1"); |
3481 | } | 3481 | } |
@@ -3489,7 +3489,7 @@ static void e2fsck_pass1(e2fsck_t ctx) | |||
3489 | if (!inode->i_dtime && inode->i_mode) { | 3489 | if (!inode->i_dtime && inode->i_mode) { |
3490 | if (fix_problem(ctx, | 3490 | if (fix_problem(ctx, |
3491 | PR_1_ZERO_DTIME, &pctx)) { | 3491 | PR_1_ZERO_DTIME, &pctx)) { |
3492 | inode->i_dtime = time(0); | 3492 | inode->i_dtime = time(NULL); |
3493 | e2fsck_write_inode(ctx, ino, inode, | 3493 | e2fsck_write_inode(ctx, ino, inode, |
3494 | "pass1"); | 3494 | "pass1"); |
3495 | } | 3495 | } |
@@ -3659,7 +3659,7 @@ static void e2fsck_pass1(e2fsck_t ctx) | |||
3659 | } | 3659 | } |
3660 | e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode, | 3660 | e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode, |
3661 | "recreate inode"); | 3661 | "recreate inode"); |
3662 | inode->i_mtime = time(0); | 3662 | inode->i_mtime = time(NULL); |
3663 | e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode, | 3663 | e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode, |
3664 | "recreate inode"); | 3664 | "recreate inode"); |
3665 | fs->block_map = save_bmap; | 3665 | fs->block_map = save_bmap; |
@@ -4169,7 +4169,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, | |||
4169 | if (pb.clear) { | 4169 | if (pb.clear) { |
4170 | inode->i_links_count = 0; | 4170 | inode->i_links_count = 0; |
4171 | ext2fs_icount_store(ctx->inode_link_info, ino, 0); | 4171 | ext2fs_icount_store(ctx->inode_link_info, ino, 0); |
4172 | inode->i_dtime = time(0); | 4172 | inode->i_dtime = time(NULL); |
4173 | dirty_inode++; | 4173 | dirty_inode++; |
4174 | ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino); | 4174 | ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino); |
4175 | ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino); | 4175 | ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino); |
@@ -4202,7 +4202,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, | |||
4202 | if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) { | 4202 | if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) { |
4203 | inode->i_links_count = 0; | 4203 | inode->i_links_count = 0; |
4204 | ext2fs_icount_store(ctx->inode_link_info, ino, 0); | 4204 | ext2fs_icount_store(ctx->inode_link_info, ino, 0); |
4205 | inode->i_dtime = time(0); | 4205 | inode->i_dtime = time(NULL); |
4206 | dirty_inode++; | 4206 | dirty_inode++; |
4207 | ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino); | 4207 | ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino); |
4208 | ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino); | 4208 | ext2fs_unmark_inode_bitmap(ctx->inode_reg_map, ino); |
@@ -5147,7 +5147,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino, | |||
5147 | /* Inode may have changed by block_iterate, so reread it */ | 5147 | /* Inode may have changed by block_iterate, so reread it */ |
5148 | e2fsck_read_inode(ctx, ino, &inode, "delete_file"); | 5148 | e2fsck_read_inode(ctx, ino, &inode, "delete_file"); |
5149 | inode.i_links_count = 0; | 5149 | inode.i_links_count = 0; |
5150 | inode.i_dtime = time(0); | 5150 | inode.i_dtime = time(NULL); |
5151 | if (inode.i_file_acl && | 5151 | if (inode.i_file_acl && |
5152 | (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) { | 5152 | (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) { |
5153 | count = 1; | 5153 | count = 1; |
@@ -6393,7 +6393,7 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf) | |||
6393 | ext2fs_icount_store(ctx->inode_link_info, ino, 0); | 6393 | ext2fs_icount_store(ctx->inode_link_info, ino, 0); |
6394 | e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode"); | 6394 | e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode"); |
6395 | inode.i_links_count = 0; | 6395 | inode.i_links_count = 0; |
6396 | inode.i_dtime = time(0); | 6396 | inode.i_dtime = time(NULL); |
6397 | e2fsck_write_inode(ctx, ino, &inode, "deallocate_inode"); | 6397 | e2fsck_write_inode(ctx, ino, &inode, "deallocate_inode"); |
6398 | clear_problem_context(&pctx); | 6398 | clear_problem_context(&pctx); |
6399 | pctx.ino = ino; | 6399 | pctx.ino = ino; |
@@ -6890,7 +6890,7 @@ static void check_root(e2fsck_t ctx) | |||
6890 | memset(&inode, 0, sizeof(inode)); | 6890 | memset(&inode, 0, sizeof(inode)); |
6891 | inode.i_mode = 040755; | 6891 | inode.i_mode = 040755; |
6892 | inode.i_size = fs->blocksize; | 6892 | inode.i_size = fs->blocksize; |
6893 | inode.i_atime = inode.i_ctime = inode.i_mtime = time(0); | 6893 | inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL); |
6894 | inode.i_links_count = 2; | 6894 | inode.i_links_count = 2; |
6895 | inode.i_blocks = fs->blocksize / 512; | 6895 | inode.i_blocks = fs->blocksize / 512; |
6896 | inode.i_block[0] = blk; | 6896 | inode.i_block[0] = blk; |
@@ -7138,7 +7138,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix) | |||
7138 | memset(&inode, 0, sizeof(inode)); | 7138 | memset(&inode, 0, sizeof(inode)); |
7139 | inode.i_mode = 040700; | 7139 | inode.i_mode = 040700; |
7140 | inode.i_size = fs->blocksize; | 7140 | inode.i_size = fs->blocksize; |
7141 | inode.i_atime = inode.i_ctime = inode.i_mtime = time(0); | 7141 | inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL); |
7142 | inode.i_links_count = 2; | 7142 | inode.i_links_count = 2; |
7143 | inode.i_blocks = fs->blocksize / 512; | 7143 | inode.i_blocks = fs->blocksize / 512; |
7144 | inode.i_block[0] = blk; | 7144 | inode.i_block[0] = blk; |
@@ -7492,7 +7492,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i) | |||
7492 | if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) { | 7492 | if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) { |
7493 | ext2fs_icount_store(ctx->inode_link_info, i, 0); | 7493 | ext2fs_icount_store(ctx->inode_link_info, i, 0); |
7494 | inode.i_links_count = 0; | 7494 | inode.i_links_count = 0; |
7495 | inode.i_dtime = time(0); | 7495 | inode.i_dtime = time(NULL); |
7496 | e2fsck_write_inode(ctx, i, &inode, | 7496 | e2fsck_write_inode(ctx, i, &inode, |
7497 | "disconnect_inode"); | 7497 | "disconnect_inode"); |
7498 | /* | 7498 | /* |
@@ -11558,7 +11558,7 @@ static int release_orphan_inodes(e2fsck_t ctx) | |||
11558 | if (!inode.i_links_count) { | 11558 | if (!inode.i_links_count) { |
11559 | ext2fs_inode_alloc_stats2(fs, ino, -1, | 11559 | ext2fs_inode_alloc_stats2(fs, ino, -1, |
11560 | LINUX_S_ISDIR(inode.i_mode)); | 11560 | LINUX_S_ISDIR(inode.i_mode)); |
11561 | inode.i_dtime = time(0); | 11561 | inode.i_dtime = time(NULL); |
11562 | } else { | 11562 | } else { |
11563 | inode.i_dtime = 0; | 11563 | inode.i_dtime = 0; |
11564 | } | 11564 | } |
@@ -12714,7 +12714,7 @@ static void check_if_skip(e2fsck_t ctx) | |||
12714 | unsigned int reason_arg = 0; | 12714 | unsigned int reason_arg = 0; |
12715 | long next_check; | 12715 | long next_check; |
12716 | int batt = is_on_batt(); | 12716 | int batt = is_on_batt(); |
12717 | time_t now = time(0); | 12717 | time_t now = time(NULL); |
12718 | 12718 | ||
12719 | if ((ctx->options & E2F_OPT_FORCE) || cflag || swapfs) | 12719 | if ((ctx->options & E2F_OPT_FORCE) || cflag || swapfs) |
12720 | return; | 12720 | return; |
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c b/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c index 855f86eac..1deae54e8 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c +++ b/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c | |||
@@ -125,9 +125,9 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) | |||
125 | if (retval) | 125 | if (retval) |
126 | goto cleanup; | 126 | goto cleanup; |
127 | 127 | ||
128 | inode.i_atime = inode.i_mtime = time(0); | 128 | inode.i_atime = inode.i_mtime = time(NULL); |
129 | if (!inode.i_ctime) | 129 | if (!inode.i_ctime) |
130 | inode.i_ctime = time(0); | 130 | inode.i_ctime = time(NULL); |
131 | inode.i_blocks = rec.bad_block_count * (fs->blocksize / 512); | 131 | inode.i_blocks = rec.bad_block_count * (fs->blocksize / 512); |
132 | inode.i_size = rec.bad_block_count * fs->blocksize; | 132 | inode.i_size = rec.bad_block_count * fs->blocksize; |
133 | 133 | ||
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c b/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c index 5bdd34682..af47aee18 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c +++ b/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c | |||
@@ -231,7 +231,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, | |||
231 | 231 | ||
232 | inode.i_size += fs->blocksize * size; | 232 | inode.i_size += fs->blocksize * size; |
233 | inode.i_blocks += (fs->blocksize / 512) * es.newblocks; | 233 | inode.i_blocks += (fs->blocksize / 512) * es.newblocks; |
234 | inode.i_mtime = inode.i_ctime = time(0); | 234 | inode.i_mtime = inode.i_ctime = time(NULL); |
235 | inode.i_links_count = 1; | 235 | inode.i_links_count = 1; |
236 | inode.i_mode = LINUX_S_IFREG | 0600; | 236 | inode.i_mode = LINUX_S_IFREG | 0600; |
237 | 237 | ||
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c b/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c index 31cc89e28..3c550d511 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c +++ b/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c | |||
@@ -117,7 +117,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs) | |||
117 | sb->s_feature_ro_compat |= | 117 | sb->s_feature_ro_compat |= |
118 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE; | 118 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE; |
119 | } | 119 | } |
120 | inode.i_ctime = time(0); | 120 | inode.i_ctime = time(NULL); |
121 | } | 121 | } |
122 | 122 | ||
123 | for (rsv_off = 0, gdt_off = fs->desc_blocks, | 123 | for (rsv_off = 0, gdt_off = fs->desc_blocks, |
@@ -209,7 +209,7 @@ out_inode: | |||
209 | inode.i_size); | 209 | inode.i_size); |
210 | #endif | 210 | #endif |
211 | if (inode_dirty) { | 211 | if (inode_dirty) { |
212 | inode.i_atime = inode.i_mtime = time(0); | 212 | inode.i_atime = inode.i_mtime = time(NULL); |
213 | retval2 = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode); | 213 | retval2 = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode); |
214 | if (!retval) | 214 | if (!retval) |
215 | retval = retval2; | 215 | retval = retval2; |
diff --git a/networking/httpd.c b/networking/httpd.c index 3a2e6b14b..fc8b51240 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -969,7 +969,7 @@ static void send_headers(int responseNum) | |||
969 | const char *error_page = NULL; | 969 | const char *error_page = NULL; |
970 | #endif | 970 | #endif |
971 | unsigned i; | 971 | unsigned i; |
972 | time_t timer = time(0); | 972 | time_t timer = time(NULL); |
973 | char tmp_str[80]; | 973 | char tmp_str[80]; |
974 | int len; | 974 | int len; |
975 | 975 | ||
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index d0a1eba81..ebf30178a 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -255,13 +255,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
255 | DEBUG("Received DECLINE"); | 255 | DEBUG("Received DECLINE"); |
256 | if (lease) { | 256 | if (lease) { |
257 | memset(lease->chaddr, 0, 16); | 257 | memset(lease->chaddr, 0, 16); |
258 | lease->expires = time(0) + server_config.decline_time; | 258 | lease->expires = time(NULL) + server_config.decline_time; |
259 | } | 259 | } |
260 | break; | 260 | break; |
261 | case DHCPRELEASE: | 261 | case DHCPRELEASE: |
262 | DEBUG("Received RELEASE"); | 262 | DEBUG("Received RELEASE"); |
263 | if (lease) | 263 | if (lease) |
264 | lease->expires = time(0); | 264 | lease->expires = time(NULL); |
265 | break; | 265 | break; |
266 | case DHCPINFORM: | 266 | case DHCPINFORM: |
267 | DEBUG("Received INFORM"); | 267 | DEBUG("Received INFORM"); |
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 64edcbb25..fb6fe01ae 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -36,6 +36,7 @@ static int read_ip(const char *line, void *arg) | |||
36 | return 1; | 36 | return 1; |
37 | } | 37 | } |
38 | 38 | ||
39 | |||
39 | static int read_mac(const char *line, void *arg) | 40 | static int read_mac(const char *line, void *arg) |
40 | { | 41 | { |
41 | return NULL == ether_aton_r(line, (struct ether_addr *)arg); | 42 | return NULL == ether_aton_r(line, (struct ether_addr *)arg); |
@@ -362,7 +363,7 @@ void FAST_FUNC write_leases(void) | |||
362 | if (leases[i].yiaddr == 0) | 363 | if (leases[i].yiaddr == 0) |
363 | continue; | 364 | continue; |
364 | 365 | ||
365 | /* screw with the time in the struct, for easier writing */ | 366 | /* Screw with the time in the struct, for easier writing */ |
366 | tmp_time = leases[i].expires; | 367 | tmp_time = leases[i].expires; |
367 | 368 | ||
368 | leases[i].expires -= curr; | 369 | leases[i].expires -= curr; |
@@ -374,7 +375,7 @@ void FAST_FUNC write_leases(void) | |||
374 | * we lose some leases on restart. Oh well. */ | 375 | * we lose some leases on restart. Oh well. */ |
375 | full_write(fd, &leases[i], sizeof(leases[i])); | 376 | full_write(fd, &leases[i], sizeof(leases[i])); |
376 | 377 | ||
377 | /* then restore it when done */ | 378 | /* Then restore it when done */ |
378 | leases[i].expires = tmp_time; | 379 | leases[i].expires = tmp_time; |
379 | } | 380 | } |
380 | close(fd); | 381 | close(fd); |
@@ -390,10 +391,10 @@ void FAST_FUNC write_leases(void) | |||
390 | 391 | ||
391 | void FAST_FUNC read_leases(const char *file) | 392 | void FAST_FUNC read_leases(const char *file) |
392 | { | 393 | { |
393 | int fd; | ||
394 | unsigned i; | ||
395 | struct dhcpOfferedAddr lease; | 394 | struct dhcpOfferedAddr lease; |
396 | int64_t written_at, curr; | 395 | int64_t written_at, time_passed; |
396 | int fd; | ||
397 | USE_UDHCP_DEBUG(unsigned i;) | ||
397 | 398 | ||
398 | fd = open_or_warn(file, O_RDONLY); | 399 | fd = open_or_warn(file, O_RDONLY); |
399 | if (fd < 0) | 400 | if (fd < 0) |
@@ -402,18 +403,19 @@ void FAST_FUNC read_leases(const char *file) | |||
402 | if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at)) | 403 | if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at)) |
403 | goto ret; | 404 | goto ret; |
404 | written_at = ntoh64(written_at); | 405 | written_at = ntoh64(written_at); |
405 | curr = time(NULL); | 406 | |
406 | if (curr < written_at) | 407 | time_passed = time(NULL) - written_at; |
407 | written_at = curr; /* lease file from future! :) */ | 408 | /* Strange written_at, or lease file from old version of udhcpd |
408 | 409 | * which had no "written_at" field? */ | |
409 | i = 0; | 410 | if ((uint64_t)time_passed > 12 * 60 * 60) |
410 | while (i < server_config.max_leases | 411 | goto ret; |
411 | && full_read(fd, &lease, sizeof(lease)) == sizeof(lease) | 412 | |
412 | ) { | 413 | USE_UDHCP_DEBUG(i = 0;) |
414 | while (full_read(fd, &lease, sizeof(lease)) == sizeof(lease)) { | ||
413 | /* ADDME: what if it matches some static lease? */ | 415 | /* ADDME: what if it matches some static lease? */ |
414 | uint32_t y = ntohl(lease.yiaddr); | 416 | uint32_t y = ntohl(lease.yiaddr); |
415 | if (y >= server_config.start_ip && y <= server_config.end_ip) { | 417 | if (y >= server_config.start_ip && y <= server_config.end_ip) { |
416 | int64_t expires = ntohl(lease.expires) + written_at - curr; | 418 | signed_leasetime_t expires = ntohl(lease.expires) - (signed_leasetime_t)time_passed; |
417 | if (expires <= 0) | 419 | if (expires <= 0) |
418 | continue; | 420 | continue; |
419 | /* NB: add_lease takes "relative time", IOW, | 421 | /* NB: add_lease takes "relative time", IOW, |
@@ -422,7 +424,7 @@ void FAST_FUNC read_leases(const char *file) | |||
422 | bb_error_msg("too many leases while loading %s", file); | 424 | bb_error_msg("too many leases while loading %s", file); |
423 | break; | 425 | break; |
424 | } | 426 | } |
425 | i++; | 427 | USE_UDHCP_DEBUG(i++;) |
426 | } | 428 | } |
427 | } | 429 | } |
428 | DEBUG("Read %d leases", i); | 430 | DEBUG("Read %d leases", i); |
diff --git a/runit/sv.c b/runit/sv.c index 7e5efdea9..20e86199a 100644 --- a/runit/sv.c +++ b/runit/sv.c | |||
@@ -445,7 +445,7 @@ int sv_main(int argc, char **argv) | |||
445 | service = argv; | 445 | service = argv; |
446 | services = argc - 1; | 446 | services = argc - 1; |
447 | 447 | ||
448 | tnow = time(0) + 0x400000000000000aULL; | 448 | tnow = time(NULL) + 0x400000000000000aULL; |
449 | tstart = tnow; | 449 | tstart = tnow; |
450 | curdir = open_read("."); | 450 | curdir = open_read("."); |
451 | if (curdir == -1) | 451 | if (curdir == -1) |
@@ -592,7 +592,7 @@ int sv_main(int argc, char **argv) | |||
592 | } | 592 | } |
593 | if (want_exit) break; | 593 | if (want_exit) break; |
594 | usleep(420000); | 594 | usleep(420000); |
595 | tnow = time(0) + 0x400000000000000aULL; | 595 | tnow = time(NULL) + 0x400000000000000aULL; |
596 | } | 596 | } |
597 | return rc > 99 ? 99 : rc; | 597 | return rc > 99 ? 99 : rc; |
598 | } | 598 | } |
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c index 6c399c746..9a73ba29c 100644 --- a/util-linux/rtcwake.c +++ b/util-linux/rtcwake.c | |||
@@ -159,7 +159,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
159 | bb_error_msg_and_die("%s not enabled for wakeup events", rtcname); | 159 | bb_error_msg_and_die("%s not enabled for wakeup events", rtcname); |
160 | 160 | ||
161 | /* relative or absolute alarm time, normalized to time_t */ | 161 | /* relative or absolute alarm time, normalized to time_t */ |
162 | sys_time = time(0); | 162 | sys_time = time(NULL); |
163 | if (sys_time == (time_t)-1) | 163 | if (sys_time == (time_t)-1) |
164 | bb_perror_msg_and_die("read system time"); | 164 | bb_perror_msg_and_die("read system time"); |
165 | rtc_time = rtc_read_time(fd, utc); | 165 | rtc_time = rtc_read_time(fd, utc); |