diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-11 21:43:07 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-11 21:43:07 +0800 |
commit | 0312ef782e11700862f8f1e4d601706cdb8e0874 (patch) | |
tree | 9c5af27126d7a4a004ed2c98fc374ade71db33bb /mbbsd/calendar.c | |
parent | 5576dd55cfc4a6843341f3cc8c2293a616889bf0 (diff) | |
download | pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.tar pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.tar.gz pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.tar.bz2 pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.tar.lz pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.tar.xz pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.tar.zst pttbbs-0312ef782e11700862f8f1e4d601706cdb8e0874.zip |
- fix crash: should check every return value of strtok_r.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3992 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/calendar.c')
-rw-r--r-- | mbbsd/calendar.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index 2205d71b..b87c774a 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -40,11 +40,9 @@ int ParseDate(const char *date, int *year, int *month, int *day) char *strtok_pos; strlcpy(buf, date, sizeof(buf)); - y = strtok_r(buf, "/", &strtok_pos); - m = strtok_r(NULL, "/", &strtok_pos); - d = strtok_r(NULL, "", &strtok_pos); - if (!y || !m || !d) - return 1; + y = strtok_r(buf, "/", &strtok_pos); if (!y) return 1; + m = strtok_r(NULL, "/", &strtok_pos);if (!m) return 1; + d = strtok_r(NULL, "", &strtok_pos); if (!d) return 1; *year = atoi(y); *month = atoi(m); |