Bitcoin Forum
December 03, 2016, 03:56:29 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [PULL] Bugfix for rfc1123Time  (Read 910 times)
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2086



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.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480780589
Hero Member
*
Offline Offline

Posts: 1480780589

View Profile Personal Message (Offline)

Ignore
1480780589
Reply with quote  #2

1480780589
Report to moderator
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2086



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


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: 1470


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, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2086



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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!