Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first element being a zero length string #983

Closed
cfpp2p opened this issue Dec 22, 2014 · 3 comments
Closed

first element being a zero length string #983

cfpp2p opened this issue Dec 22, 2014 · 3 comments

Comments

@cfpp2p
Copy link

cfpp2p commented Dec 22, 2014

Referencing #896

The fix for closed #896 seems incomplete. static private function encode_string remains in need of patch (per closed #896). Please correct me if I'm in error.

I'm seeing below as not patched in Torrent.php

    static private function encode_string( $string ) 
    {
            return(strlen( $string ) . ':' . $string);
    }

zero length string

re: #896

The problem above ends up creating a list with the first element being a zero length string. Since there should never be a valid reason to have a zero length string in the bencoded data, we can avoid it (and any other place where a zero length string might get created) by checking the length of the string at encoding time and return an empty string instead of a "0:" string.

Fix:

    static private function encode_string( $string )
    {
    if( strlen( $string ))
    return(strlen( $string ) . ':' . $string);
    else
    return "";
    }

I don't see where this particular issue was fixed in the code and newly created torrents can still be created with the first element being a zero length string.

@Novik
Copy link
Owner

Novik commented Dec 22, 2014

Fragment from valid torrent:
comment45:Please seed this torrent as long as possible!13:comment.utf-80:10:created by
Fragment from invalid torrent (i.e. created with this patch):
comment45:Please seed this torrent as long as possible!13:comment.utf-810:created by

Do you see difference?

@cfpp2p
Copy link
Author

cfpp2p commented Dec 22, 2014

I'm trying to resolve an issue with ruTorrent and transmission.
https://trac.transmissionbt.com/ticket/5517#comment:66

currently the transmission project receives somewhat frequent complaints that transmission rejects torrents created by ruTorrent if the "first element being a zero length string".

Where the actual problem resides? It's my personal opinion the the responsibility resides with transmission and not with ruTorrent .

I'm trying to become informed on the current state of ruTorrent concerning torrents with "first element being a zero length string" not suggesting a particular change but just the current status.

No matter what, transmission (I believe) should accept new and old torrents from ruTorrent whether or not the "first element being a zero length string".

@Novik
Copy link
Owner

Novik commented Dec 22, 2014

This is, of course, a ruTorrent error (i.e. an error in the PHP class of Adrien), but it can't be fixed by such way, and yes, function encode_string still unchanged.
Function folder was corrected (5 month ago), and, IMHO, this should fix this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants