Wireshark-dev: [Wireshark-dev] Timestamp validation - caller or callee ?

From: chuck c <bubbasnmp@xxxxxxxxx>
Date: Fri, 22 Jul 2022 11:27:27 -0500
For functions that process timestamp strings, should the function eat/process the entire string or are there cases where it's ok to just use part?

editcap.c:

            if ((0 < iso8601_to_nstime(&in_time, ws_optarg, ISO8601_DATETIME)) || (0 < unix_epoch_to_nstime(&in_time, ws_optarg))) {

Is this an acceptable solution in the case where a bad timestamp string is passed on the command line to editcap (caller validates)?

            if ((strlen(ws_optarg) == iso8601_to_nstime(&in_time, ws_optarg, ISO8601_DATETIME)) || (strlen(ws_optarg) == unix_epoch_to_nstime(&in_time, ws_optarg))) {

Debug/printf output:
C:\Development\wsbuild64_2022>run\RelWithDebInfo\editcap.exe -V -A 2005-09-06T01:22:21 -B 2005-09-06 p:\wap_google.pcap split
Timestamp: 2005-09-06T01:22:21, Length: 19
iso8601_to_nstime: 19
unix_epoch_to_nstime: 4
Timestamp: 2005-09-06, Length: 10
iso8601_to_nstime: 0    <----   callee validated and said nope
unix_epoch_to_nstime: 4
editcap: "2005-09-06" isn't a valid date and time