transmit an array via socket

Bryan Olson fakeaddress at nowhere.org
Sat Oct 27 06:08:48 EDT 2007


Hendrik van Rooyen wrote:
> "Jeff Pang" <p...uno.com> wrote:
>> I want to transmit an array via socket from a host to another.
>> How to do it? thank you.
> 
> pickle it and send it and unpickle it on the other side.
> 
> See the cPickle module docs for loads and dumps.

In particular note:

     Warning: The pickle module is not intended to be secure
     against erroneous or maliciously constructed data. Never
     unpickle data received from an untrusted or
     unauthenticated source.

Pickle works great for lots of things, but combining
pickle and socket is scary. If an unfriendly can connect
to our socket, they can feed us a *poison* pickle. The
marshal module is at least as bad.

The marshaling in RPC facilities tends to be much safer.


-- 
--Bryan



More information about the Python-list mailing list