y2k-dst
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
y2k-dst [2021/08/31 20:56] – wiki_admin | y2k-dst [2022/03/19 17:32] (current) – added setclk patch info and link to original a.org thread wiki_admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Amix & Y2K ====== | + | ===== Amix & Y2K ===== |
- | The built-in setclk is not Y2K compatible and it will complain about "date: bad conversion" | + | The built-in setclk |
- | The built-in setclk | + | A patched version |
- | FIXME instructions on how to upgrade: basically just overwrite every instance of setclk with the fixed version. | + | The discussion that led to the patched setclk utility is presented below. Thanks to Failure, Piru and a_petri [[https:// |
+ | Piru: | ||
+ | |||
+ | > The bug was in sscanf() using %02d for the year. The year is 3 digits with years 2000++ so only first two first digits were parsed (year ended up 10 instead of 106). Also various buffers had to be extended to accommodate the extra char so no buffer overflow will occur. | ||
+ | > | ||
+ | > However, if date can't grock it (which might well be the case), / | ||
+ | > | ||
+ | > If you find the patch above useful please feel free to use it as you wish. I hereby place it in public domain. | ||
+ | > | ||
+ | > Now assuming / | ||
+ | |||
+ | < | ||
+ | |||
+ | --- setclk.c-orig Sat Feb 11 02:48:57 2006 | ||
+ | +++ setclk.c Sat Feb 11 10:41:14 2006 | ||
+ | @@ -51,7 +51,7 @@ | ||
+ | |||
+ | if (!strcmp(*argv, | ||
+ | { | ||
+ | - char buffer[11]; | ||
+ | + char buffer[12]; | ||
+ | |||
+ | retval = read_clock(buffer); | ||
+ | |||
+ | @@ -80,7 +80,7 @@ | ||
+ | if (argc == 1) | ||
+ | { | ||
+ | time_t thetime = read_from_clock_device(); | ||
+ | - char buffer[BUFSIZ*2], | ||
+ | + char buffer[BUFSIZ*2], | ||
+ | |||
+ | /* | ||
+ | ** Set the system time to what the hardware thinks is correct. | ||
+ | @@ -138,7 +138,7 @@ | ||
+ | |||
+ | if (set_clock) | ||
+ | { | ||
+ | - char buffer[11]; | ||
+ | + char buffer[12]; | ||
+ | struct tm *tm; | ||
+ | time_t thetime; | ||
+ | |||
+ | @@ -175,7 +175,7 @@ | ||
+ | |||
+ | if (display_clock) | ||
+ | { | ||
+ | - char buffer[11]; | ||
+ | + char buffer[12]; | ||
+ | |||
+ | retval = read_clock(buffer); | ||
+ | |||
+ | @@ -299,7 +299,7 @@ | ||
+ | return FALSE; | ||
+ | } | ||
+ | |||
+ | - if (sscanf(buffer, | ||
+ | + if (sscanf(buffer, | ||
+ | & | ||
+ | { | ||
+ | (void) fprintf(stderr, | ||
+ | </ | ||
+ | |||
+ | a_petri: | ||
+ | |||
+ | > I have stumbled to this topic accidentally, | ||
+ | > | ||
+ | > I investigated the problem, and I found some interesting facts: | ||
+ | > | ||
+ | > - The setclk command is able to handle the " | ||
+ | > | ||
+ | > - The date command is able to handle the four-digit year format, but not the three-digit format. | ||
+ | > | ||
+ | > - The two commands call each other in a tricky way: setclk without arguments call date with an argument decoded from reading the RTC, and date with a single date argument calls setclk with the -s argument. | ||
+ | > | ||
+ | > Therefore I tried to modify the argument passed to the date command in setclk.c to the four-digit year format. | ||
+ | > | ||
+ | > My patch is the following (against Piru's version published here). With this patch, the compiled setclk binary seems to work correctly with both pre-Y2K and post-Y2K dates. | ||
+ | |||
+ | < | ||
+ | *** setclk.c.piru | ||
+ | --- setclk.c | ||
+ | ************** | ||
+ | *** 81,87 **** | ||
+ | --- 81,87 ---- | ||
+ | if (argc == 1) | ||
+ | { | ||
+ | time_t thetime = read_from_clock_device(); | ||
+ | - char buffer[BUFSIZ*2], | ||
+ | + char buffer[BUFSIZ*2], | ||
+ | | ||
+ | /* | ||
+ | ** Set the system time to what the hardware thinks is correct. | ||
+ | *************** | ||
+ | *** 96,101 **** | ||
+ | --- 96,109 ---- | ||
+ | } | ||
+ | | ||
+ | convert_time(thetime, | ||
+ | + if (tmpbuf[8] == ' | ||
+ | + { | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + } | ||
+ | sprintf(buffer, | ||
+ | system(buffer); | ||
+ | </ | ||
===== 2007 DST changes ===== | ===== 2007 DST changes ===== |
y2k-dst.1630436164.txt.gz · Last modified: 2021/09/19 17:59 (external edit)