Bitcoin Forum
May 04, 2024, 07:35:40 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [PULL] Bugfix for rfc1123Time  (Read 1131 times)
Luke-Jr (OP)
Legendary
*
expert
Offline Offline

Activity: 2576
Merit: 1186



View Profile
April 09, 2011, 02:39:58 AM
 #1

Someone in #bitcoin-discussion was having problems with JSON-RPC and it turned out to be related to their timezone overflowing the rfc1123Time function's buffer. My 'rfc1123Time_localefix' branch addresses the problem by forcing the locale and timezone to POSIX and UTC for its purposes (and resetting it back later).

git fetch git://gitorious.org/~Luke-Jr/bitcoin/luke-jr-bitcoin.git rfc1123Time_localefix && git diff 454bc8..FETCH_HEAD && git merge FETCH_HEAD

I suspect the JSON-RPC has other locale problems as well, in case someone wants to look into it further.

1714808140
Hero Member
*
Offline Offline

Posts: 1714808140

View Profile Personal Message (Offline)

Ignore
1714808140
Reply with quote  #2

1714808140
Report to moderator
1714808140
Hero Member
*
Offline Offline

Posts: 1714808140

View Profile Personal Message (Offline)

Ignore
1714808140
Reply with quote  #2

1714808140
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714808140
Hero Member
*
Offline Offline

Posts: 1714808140

View Profile Personal Message (Offline)

Ignore
1714808140
Reply with quote  #2

1714808140
Report to moderator
1714808140
Hero Member
*
Offline Offline

Posts: 1714808140

View Profile Personal Message (Offline)

Ignore
1714808140
Reply with quote  #2

1714808140
Report to moderator
1714808140
Hero Member
*
Offline Offline

Posts: 1714808140

View Profile Personal Message (Offline)

Ignore
1714808140
Reply with quote  #2

1714808140
Report to moderator
Luke-Jr (OP)
Legendary
*
expert
Offline Offline

Activity: 2576
Merit: 1186



View Profile
April 09, 2011, 03:08:00 AM
 #2

Correction to my above summary: bitcoind does use gmtime to get the correct UTC time, but the problem was that Windows still tries to put the local timezone for %Z rather than UTC as is being encoded.

Actually, according to the RFC, numeric timezones should be used (not names). So rather than force TZ to UTC, the buffer should be extended and %z used instead of %Z. I do not have any idea if Windows complies with %z better than %Z, so I am leaving the temporarily-set-TZ hack in. Otherwise, my branch now uses %z.

Please note that the timezone is not the only issue here. The locale must also be forced to POSIX to get the usual weekday (Sun-Sat) and month (Jan-Dec) abbreviations, rather than some local variant.

Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
April 09, 2011, 04:25:16 PM
 #3

GMT is always +0:00, so why not hardcode that instead of using %z or %Z?

RE: changing locale:  good idea.

How often do you get the chance to work on a potentially world-changing project?
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


View Profile
April 09, 2011, 05:11:34 PM
 #4

GMT is always +0:00, so why not hardcode that instead of using %z or %Z?

Yep, that should work just fine.


Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Luke-Jr (OP)
Legendary
*
expert
Offline Offline

Activity: 2576
Merit: 1186



View Profile
April 09, 2011, 05:39:54 PM
 #5

Ok, rewrote my branch to only set locale and hard-code "+0000"; good idea.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!