Made btpd accept bencoded dictionaries whose keys are not in alphabetical order. #30

wants to merge 1 commit into from

1 participant


A few weeks ago, I sent the following message to the mailing list (at

Subject: Not sure if this is a bug! (btpd 0.16)

Hi! This is not a full bug report, because I'm not sure if this is
something you guys even consider a bug.

I have an improperly-formatted .torrent file; specifically, the
"announce" key comes last in the top-level dictionary -- if it were
properly formatted, it would come first. (In a bencoded dictionary,
the keys are supposed to be in alphabetical order.) When I try to add
this torrent using bcli, I get an error:

error loading '[path]' (Invalid argument).

Clearly, the problem here is the badly-formatted .torrent file, but
other clients handle it fine, and the .torrent file does contain all
of the information that the daemon needs. If it were me, I would have
btpd accept this kind of bad input, but different projects have
different policies.

If it's better for me to file a real bug report, let me know and I'll
make it reproducible. I haven't looked too closely to see how much
work it would take to fix, but I'd be more than happy to submit a


  • BW

I fixed the "bug." It's certainly a corner case but it doesn't hurt either. Let me know what you think!


Hm, I wrote this a long time ago, and since have deleted my account and then re-activated it. This pull request is thus an orphan. I re-posted it under my new account here: #36. If this patch is accepted, please accept that pull request, and delete this one. Thanks!

@queueRAM queueRAM was assigned Apr 26, 2012
@queueRAM queueRAM closed this in c408419 May 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment