RE: Encrypted Glib::ustring(s)
- From: "Gavin Lambert" <gavin lambert compacsort com>
- To: "'Glus Xof'" <gtglus gmail com>, <gtkmm-list gnome org>
- Subject: RE: Encrypted Glib::ustring(s)
- Date: Wed, 23 Nov 2011 11:19:22 +1300
Quoth Glus Xof:
> The question is that sometimes, when I try to send encrypted messages
> throw socket connections using the low-level gio socket objects, the
> received messages are broken, uncomplete.
>
> I wonder if it's due to any specifical bit sequence... but, I haven't
> enough knowledge to test and find the ultimate solution.
[...]
> gsize Gio::Socket->send (Glib::ustring);
> Glib::ustring Gio::Socket->receive(gsize size);
Glib::ustring assumes that its contents are a UTF-8 encoded string. If you
are encrypting this with any method that does not produce a UTF-8 encoded
string as output (ie. most of them), then it's not safe to put it back into
a Glib::ustring. Thus, you should be using a byte array instead (or
*possibly* a std::string, if you can guarantee that there are no
string-conversion steps occurring along the way).
I'm not really familiar with Gio::Socket (or its underlying C API), but if
it does not provide such an API then you should either rewrap it or use the
C API directly, since it's likely that the C API does not perform string
conversion.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]