Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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
@queueRAM queueRAM closed this in c408419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2011
  1. Allow btpd to accept bencoded dictionaries whose keys are not in alph…

    Brian Waters authored
    …abetical order.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 3 deletions.
  1. +1 −3 misc/benc.c
4 misc/benc.c
@@ -233,10 +233,8 @@ benc_dget_any(const char *p, const char *key)
cmp = strncmp(bstr, key, blen);
if (cmp == 0 && len == blen)
return p;
- else if (cmp <= 0)
- p = benc_next(p);
- return NULL;
+ p = benc_next(p);
return NULL;
Something went wrong with that request. Please try again.