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

sent url includes trailing \0 byte #112

Open
Akuli opened this issue Sep 8, 2021 · 2 comments
Open

sent url includes trailing \0 byte #112

Akuli opened this issue Sep 8, 2021 · 2 comments

Comments

@Akuli
Copy link

Akuli commented Sep 8, 2021

fiche/fiche.c

Lines 661 to 665 in 4bba916

char url[len];
snprintf(url, len, "%s%s%s%s", c->settings->domain, "/", slug, "\n");
// Send the response
write(c->socket, url, len);

I first noticed this problem a few years ago when this code was introduced and it broke the pastebin plugin of my editor. I changed the plugin to strip away the \0 byte, so maybe it is now a feature, and not a bug :)

@divinity76
Copy link

divinity76 commented May 2, 2022

i think the null byte is intended behavior, as far as a termbin.com "protocol" goes, the null byte means "end of transmission, you can stop select()'ing now, there's no more data", i do like

            socket_recv($socket, $url_chunk, 99, MSG_DONTWAIT);
            $full_url .= $url_chunk;
            if (substr($url_chunk, -1) === "\x00") {
                break;
            }

@Akuli
Copy link
Author

Akuli commented May 2, 2022

You can use \n as the end-of-transmission byte, regardless of whether the null byte is there or not.

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