diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-16 15:17:40 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-16 15:17:40 +0800 |
commit | e5ee21752e651dd5e658632e5d1869b360d573d2 (patch) | |
tree | e7add7a89ae7e69df7d80904e803401b5afa60f9 /daemon/utmpd/utmpserver3.c | |
parent | 20e713a15d403569e80a1461634628fb12996a47 (diff) | |
download | pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.tar pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.tar.gz pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.tar.bz2 pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.tar.lz pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.tar.xz pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.tar.zst pttbbs-e5ee21752e651dd5e658632e5d1869b360d573d2.zip |
* fix compile error
* fix boundary condition if uid == MAX_USERS
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4634 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'daemon/utmpd/utmpserver3.c')
-rw-r--r-- | daemon/utmpd/utmpserver3.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/daemon/utmpd/utmpserver3.c b/daemon/utmpd/utmpserver3.c index 83fa6285..30894c5d 100644 --- a/daemon/utmpd/utmpserver3.c +++ b/daemon/utmpd/utmpserver3.c @@ -32,15 +32,15 @@ int action_frequently(int uid) unsigned short lastlogin; // truncated time_t unsigned char minute_count; unsigned char hour_count; - } flooding[MAX_USERS]; + } flooding[MAX_USERS+1]; if(minute!=flood_base_minute) { - for(i=0; i<MAX_USERS; i++) + for(i=0; i<=MAX_USERS; i++) flooding[i].minute_count=0; flood_base_minute=minute; } if(hour!=flood_base_hour) { - for(i=0; i<MAX_USERS; i++) + for(i=0; i<=MAX_USERS; i++) flooding[i].hour_count=0; flood_base_hour=hour; } @@ -242,11 +242,16 @@ void connection_client(int cfd, short event, void *arg) } evbuffer_remove(cs->evb, &index, sizeof(index)); evbuffer_remove(cs->evb, &uid, sizeof(uid)); - if (index >= USHM_SIZE) { + if (index >= USHM_SIZE || index < 0) { fprintf(stderr, "bad index=%d\n", index); cs->state = FSM_EXIT; break; } + if (uid > MAX_USERS || uid <= 0) { + fprintf(stderr, "bad uid=%d\n", uid); + cs->state = FSM_EXIT; + break; + } count_login++; processlogin(cs, uid, index); if (count_login >= 4000 || (time(NULL) - begin_time) > 30*60) |