Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2767 closed Bug (fixed)

DHT-formatted dictionaries are incorrect

Reported by: jch Owned by: Juliusz
Priority: Normal Milestone: 1.93
Component: Transmission Version: 1.70
Severity: Normal Keywords: dht
Cc: jch@…

Description

The BitTorrent? specification requires bencoded dictionaries to be sorted lexicographically according to the key. The dictionaries included in DHT messages do not obey that restriction.

Fortunately, other clients do not seem to mind, but this ought to be fixed.

Change History (12)

comment:1 Changed 11 years ago by charles

jch: a question about how you want to handle this... if I were to strip the other libtransmission dependencies from bencode.[ch] would that make you more likely to use it? Or are you wanting to keep it as low-level / self-contained wrt using snprintf() etc?

comment:2 Changed 11 years ago by jch

how you want to handle this...

Just by reordering the statements in the send_* functions. Actually, now that I look at the code, I see that most, perhaps all, are already ordered properly, since I was looking at packet traces of real DHT traffic when I was implementing them.

if I were to strip the other libtransmission dependencies from bencode.[ch] would that make you more likely to use it?

Recall that this code is not only for libtransmission -- it was originally written for Hekate, which is a very different design from libtransmission. The fact that I could include it into libtransmission in a few hours (most of which were spent grepping through the transmission sources) is the effect of my paranoic avoiding of any external libraries.

If you can find a clean solution that doesn't create problems for Hekate (either now or in the future), I'm very much interested. Not because of the formatting, but because of the parsing, which is one of the worst hacks that I've written in a while.

Oh, and to add insult to injury -- Hekate is under the MIT/X11 licence.

--Juliusz

comment:3 Changed 11 years ago by charles

Looking through the bencode source code, I think it's better to just sort the messages you're building by hand in the DHT code. libtransmission's bencode parser/generator has json support tied into it and uses libevent's "struct evbuffer" as a growable string.

Do you have a patch for this already? If so I'd be happy to use it in Transmission.

comment:4 Changed 11 years ago by livings124

  • Cc jch@… added

Adding Juliusz to cc list incase he hasn't seen this.

comment:5 follow-up: Changed 11 years ago by jch

Adding Juliusz to cc list in case he hasn't seen this.

Charles,

Sorry for not being more timely recently, but my laptop has been stolen, and I'm currently using my old one which has a tiny screen, which makes development somewhat uncomfortable. (I'm not allowed to use BitTorrent? on my desktop machine.)

(Now I understand why I encrypt the disk of my laptops ;-)

--Juliusz

comment:6 in reply to: ↑ 5 Changed 11 years ago by charles

Replying to jch:

but my laptop has been stolen, and I'm currently using my old one which has a tiny screen, which makes development somewhat uncomfortable.

Argh, that's awful. I feel your pain.

comment:7 Changed 11 years ago by jch

  • Owner changed from jch to charles

This is fixed in dht-0.15, which is now available.

comment:8 Changed 11 years ago by charles

  • Milestone changed from None Set to 2.00
  • Status changed from new to assigned

Fixed in trunk for 2.00 by r10423, which upgrades our DHT snapshot to dht-0.15 from http://www.pps.jussieu.fr/~jch/software/files/dht-0.15.tar.gz

comment:9 Changed 11 years ago by charles

  • Owner changed from charles to Juliusz
  • Status changed from assigned to new

comment:10 Changed 11 years ago by charles

  • Component changed from libtransmission to Transmission
  • Resolution set to fixed
  • Status changed from new to closed

comment:11 Changed 11 years ago by charles

  • Milestone changed from 2.00 to 1.93

15:55:22 < CIA-40> charles * r10597 /branches/1.9x/third-party/dht/ (CHANGES dht.c): (1.9x third-party) backport r10423 for #2767 "DHT-formatted dictionaries are incorrect"

comment:12 Changed 11 years ago by charles

  • Priority changed from Low to Normal
  • Severity changed from Minor to Normal
Note: See TracTickets for help on using tickets.