Bitcoin Forum
March 27, 2017, 05:07:04 AM *
News: Latest stable version of Bitcoin Core: 0.14.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [PULL] Bugfix for rfc1123Time  (Read 951 times)
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2128



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.

1490591224
Hero Member
*
Offline Offline

Posts: 1490591224

View Profile Personal Message (Offline)

Ignore
1490591224
Reply with quote  #2

1490591224
Report to moderator
1490591224
Hero Member
*
Offline Offline

Posts: 1490591224

View Profile Personal Message (Offline)

Ignore
1490591224
Reply with quote  #2

1490591224
Report to moderator
1490591224
Hero Member
*
Offline Offline

Posts: 1490591224

View Profile Personal Message (Offline)

Ignore
1490591224
Reply with quote  #2

1490591224
Report to moderator
There are several different types of Bitcoin clients. EWallets are like banks -- a central organization has complete control over your money. You shouldn't put much money in EWallets.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1490591224
Hero Member
*
Offline Offline

Posts: 1490591224

View Profile Personal Message (Offline)

Ignore
1490591224
Reply with quote  #2

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

Activity: 2128



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



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!