Changeset 41
- Timestamp:
- 05/18/07 17:28:15
(2 years ago)
- Author:
- csellers
- Message:
Added overflow check for handling array of failure times
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r40 |
r41 |
|
| 516 | 516 | lock_time applies */ |
|---|
| 517 | 517 | tally->fail_cnt = oldcnt; |
|---|
| 518 | | /* TODO check for out of fail_time bounds */ |
|---|
| 519 | | tally->fail_time[oldcnt] = 0; |
|---|
| | 518 | tally->fail_time[(oldcnt>TALLYLOG_FAIL_TIME_COUNT) ? |
|---|
| | 519 | TALLYLOG_FAIL_TIME_COUNT-1 : |
|---|
| | 520 | oldcnt-1] = 0; |
|---|
| 520 | 521 | |
|---|
| 521 | 522 | if (!(opts->ctrl & OPT_QUIET)) { |
|---|
| … | … | |
| 566 | 567 | /* to remember old fail time (for locktime) */ |
|---|
| 567 | 568 | if (oldtime && tally.fail_cnt > 0) { |
|---|
| 568 | | /* TODO check for out of fail_time bounds */ |
|---|
| 569 | | *oldtime = (time_t)tally.fail_time[tally.fail_cnt-1]; |
|---|
| | 569 | *oldtime = (time_t)tally.fail_time[ |
|---|
| | 570 | (tally.fail_cnt>TALLYLOG_FAIL_TIME_COUNT) ? |
|---|
| | 571 | TALLYLOG_FAIL_TIME_COUNT-1 : |
|---|
| | 572 | tally.fail_cnt-1]; |
|---|
| 570 | 573 | } |
|---|
| 571 | 574 | |
|---|
| 572 | | /* TODO check for out of fail_time bounds */ |
|---|
| 573 | | tally.fail_time[tally.fail_cnt] = time(NULL); |
|---|
| | 575 | tally.fail_time[(tally.fail_cnt>=TALLYLOG_FAIL_TIME_COUNT) ? |
|---|
| | 576 | TALLYLOG_FAIL_TIME_COUNT-1 : |
|---|
| | 577 | tally.fail_cnt] = time(NULL); |
|---|
| 574 | 578 | |
|---|
| 575 | 579 | (void) pam_get_item(pamh, PAM_RHOST, &remote_host); |
|---|
| … | … | |
| 823 | 827 | |
|---|
| 824 | 828 | pwent = getpwuid(uid); |
|---|
| 825 | | /* TODO check for out of fail_time bounds */ |
|---|
| 826 | | fail_time = tally->fail_time[tally->fail_cnt-1]; |
|---|
| | 829 | fail_time = tally->fail_time[ |
|---|
| | 830 | (tally->fail_cnt>TALLYLOG_FAIL_TIME_COUNT) ? |
|---|
| | 831 | TALLYLOG_FAIL_TIME_COUNT-1 : |
|---|
| | 832 | tally->fail_cnt-1]; |
|---|
| 827 | 833 | tm = localtime(&fail_time); |
|---|
| 828 | 834 | strftime (ptime, sizeof (ptime), "%D %H:%M:%S", tm); |
|---|
| r40 |
r41 |
|
| 39 | 39 | #ifndef _TALLYLOG_H |
|---|
| 40 | 40 | #define _TALLYLOG_H |
|---|
| | 41 | #define TALLYLOG_FAIL_TIME_COUNT 9 |
|---|
| 41 | 42 | |
|---|
| 42 | 43 | #include <stdint.h> |
|---|
| … | … | |
| 46 | 47 | uint16_t reserved; /* reserved for future use */ |
|---|
| 47 | 48 | uint16_t fail_cnt; /* failures since last success */ |
|---|
| 48 | | uint64_t fail_time[9]; /* time of previous failures */ |
|---|
| | 49 | uint64_t fail_time[TALLYLOG_FAIL_TIME_COUNT]; /* time of previous failures */ |
|---|
| 49 | 50 | }; |
|---|
| 50 | 51 | /* 64 bytes / entry */ |
|---|
Download in other formats:
* Generating other formats may take time.