Re: Avoiding string break...



2010/5/8 Mark Roberts <gtkmm manumark de>:
> Dear Glus,
>
>>>> Yesterdary, I posted the sources of an example codes [...]
>
>>> It is often suggested that a problem be reduced to a minimal program
>>> before
>>> posting it to the list. [...]
>
>> It's not necessary to look all the code, just if you need some more
>> data or want to run something in your computer... The question is that
>> in some cases (not all !!!) an std::string with encrypted values is
>> not sent entirely (through the Gio::Socket::send() &
>> Gio::Socket::receive() methods...). (hypothesis:) When the client
>> tries to decrypt this partial string throws an std::bad_alloc
>> exception instance (maybe, because it's, in fact, incomplete).
>>
>> I haven't enough knowledge to find what happens inside this string, if
>> so. But in any cases, I need to ask you some help. Maybe, the
>> encryption routines are not the most appropiate. I choosen AES because
>> -as I know- is one of the most powerful symmetric encryption
>> algorithms.
>
> You want to know why your program isn't working. You think the
> encryption/decryption may be losing part of your data. Or there may be a
> problem with zero-bytes embedded in your data. You have written a
> client-server app and may have a mistake in your code.

Not exactly... I think that the string is always well-formed both at
the exit of the encryption process and just before the transfert
through the socket, but the problem seems to be that this string
doesn't arrive entirely to the other side; I mean, when I read the
encrypted string from the buffer's socket, sometimes (not always), I
don't get the whole string...

I need some help from you to know what happens with it .

Glus

> In order to solve your problem you need to decouple these. Rewrite the
> program (a) without encryption/decryption. Does it work now? (b) without
> sockets and client-server stuff. Does it work now? (c) run the program with
> particular data, for instance data without embedded zeros or with only
> zeros, or particularly short strings or empty strings.  (d) think of other
> possibilities and leave them out.

> In other words: write a simpler and smaller program and find the error in
> that. It you have a small and short program and can't find the error, post
> it on this list.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]