Skip to content

Commit

Permalink
Merge pull request #913 from xexyl/formed-timestamp-usec
Browse files Browse the repository at this point in the history
  • Loading branch information
lcn2 authored Jul 14, 2024
2 parents c6c62ed + 134cbaa commit 7fc8273
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Major changes to the IOCCC entry toolkit

## Release 1.2.4 2024-07-14

Add constants for `test_formed_timestamp_usec()` in `entry_util.c`.


## Release 1.2.3 2024-07-12

Expand Down
9 changes: 5 additions & 4 deletions soup/entry_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2992,13 +2992,14 @@ test_formed_timestamp_usec(int formed_timestamp_usec)
/*
* validate count
*/
if (formed_timestamp_usec < 0) {
if (formed_timestamp_usec < MIN_FORMED_TIMESTAMP_USEC) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: formed_timestamp_usec: %d < 0", formed_timestamp_usec);
"invalid: formed_timestamp_usec: %d < %d", formed_timestamp_usec, MIN_FORMED_TIMESTAMP_USEC);
return false;
} else if (formed_timestamp_usec > 999999) {
} else if (formed_timestamp_usec > MAX_FORMED_TIMESTAMP_USEC) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: formed_timestamp_usec: %d > 999999", formed_timestamp_usec);
"invalid: formed_timestamp_usec: %d > MAX_FORMED_TIMESTAMP_USEC %d", formed_timestamp_usec,
MAX_FORMED_TIMESTAMP_USEC);
return false;
}
json_dbg(JSON_DBG_MED, __func__, "formed_timestamp_usec is valid");
Expand Down
3 changes: 3 additions & 0 deletions soup/limit_ioccc.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
#define MAX_TIMESTAMP_LEN (48) /* 28 + 20 more padding for locate */
#define MAX_CLOCK_ERROR ((42*60)-1) /* maximum seconds allowed for a clock to be in error */

#define MIN_FORMED_TIMESTAMP_USEC (1) /* minimum formed_timestamp_usec value */
#define MAX_FORMED_TIMESTAMP_USEC (999999) /* maximum formed_timestamp_usec value */

/*
* Be careful not to change this value as it will invalidate all IOCCC timestamps < this value
*/
Expand Down

0 comments on commit 7fc8273

Please sign in to comment.