unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 46342@debbugs.gnu.org
Subject: bug#46342: 28.0.50; socks-send-command munges IP address bytes to UTF-8
Date: Sat, 06 Feb 2021 06:19:55 -0800	[thread overview]
Message-ID: <87r1lt2s8k.fsf@neverwas.me> (raw)
In-Reply-To: <83pn1do008.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 06 Feb 2021 14:26:31 +0200")

Hi Eli. Thanks for the quick reply.

Eli Zaretskii <eliz@gnu.org> writes:

> What I don't understand is what is the "appropriate" encoding in this
> case. Can you explain why you use literal bytes in the test?  What
> are those bytes supposed to stand for, and which program is supposed
> to receive this sequence of bytes on the other end of the connect
> command?

Re appropriate encoding: correct me if I'm wrong (internet), but among
the Emacs coding systems, it'd be latin-1. In the proposed patch for
socks-send-command, swapping out the call to unibyte-string with
(encode-coding-string address 'latin-1) has the same effect of
preserving, say, char 216 as the single byte "\330" and not "\303\230".

Re literal bytes in test(s): I'm assuming you mean all the vectors. If
that's annoying or distracting, my apologies. I used them for no other
reason than I thought them easier to read. I also found them less error
prone than octal or hex escapes in strings, as warned about in (info
"(elisp) Non-ASCII in Strings"). However, I'm happy to follow whatever
the convention is.

Re meaning of the bytes: they stand for the fields in SOCKS 4 messages.
The protocol is byte oriented, so it's easy enough to read with tcpdump
since there's no meticulous packing going on when serializing, just
verbatim octets. Not the most economical, but after a brief negotiation,
it's off to proxying.

For example, you'd read

  4 1 0 80 93 184 216 34

as version 4, command 1 (connect), port 80 (2 bytes, big endian to 65535),
IPv4 address 93.184.216.34

Re program on the other end: this would be any program offering a proxy
service that speaks the same protocol. Popular ones include tor and ssh.
There's also a "bind" command that allows your client (Emacs) to act as
a server and listen/accept connections on the remote end as if they were
present on your local network.

I'm no expert, but I'll do my best to answer any further questions.
Thanks so much and enjoy your weekend!





  reply	other threads:[~2021-02-06 14:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-06 11:46 bug#46342: 28.0.50; socks-send-command munges IP address bytes to UTF-8 J.P.
2021-02-06 12:26 ` Eli Zaretskii
2021-02-06 14:19   ` J.P. [this message]
2021-02-06 15:15     ` Eli Zaretskii
2021-02-07 14:22       ` J.P.
2021-02-09 15:17       ` J.P.
2021-02-09 16:14         ` Eli Zaretskii
2021-02-10 13:16           ` J.P.
2021-02-10 16:04             ` Eli Zaretskii
2021-02-11 14:58               ` J.P.
2021-02-11 15:28                 ` Eli Zaretskii
2021-02-12 14:30                   ` J.P.
2021-02-12 15:04                     ` Eli Zaretskii
2021-02-13 15:43                       ` J.P.
2021-02-17 14:59                       ` J.P.
2021-02-20  9:33                         ` Eli Zaretskii
2021-02-20 10:13                           ` J.P.
2021-02-20 11:08                             ` Eli Zaretskii
2021-02-20 15:08                               ` J.P.
2021-02-20 15:19                                 ` Eli Zaretskii
2021-02-20 10:41                           ` J.P.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1lt2s8k.fsf@neverwas.me \
    --to=jp@neverwas.me \
    --cc=46342@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).