gomd-devel
[Top][All Lists]
Advanced

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

Re: [gomd-devel] A huge problem


From: Matthias Rechenburg
Subject: Re: [gomd-devel] A huge problem
Date: Fri, 18 Apr 2003 13:02:27 +0200
User-agent: KMail/1.4.3

Hi JP, 

On Freitag 18 April 2003 02:02, Gian Paolo Ghilardi wrote:
> Hi all.
>
> I've found an huge problem while socket connection in gomd.cpp.
> To send a msg, we use *tcp() << "STRING TO SEND"
> To get a string, we use *tcp() >> strBuffer (strBuffer is a string or a
> char*,...)
>
> The problem:
>
> *tcp() >> strBuffer works but if the string (sent by teh client) contains
> white spaces, only the first word will be put in strBuffer.

ok, got it ;)

>
> Please check this mail.
> http://mail.gnu.org/archive/html/bug-commoncpp/2003-02/msg00002.html

there are two possible solutions i would like to suggest.
1) when reading the request from the user (or client application) it should
   be ckecked e.g. if it has a valid size to avoid buffer-offerflows in the
   later read (this should be done generally. it can be done easly be checking
   the string.size() before sending the request).
   Then we could e.g. just replace all white-spaces with "_"
   and send the request as one string without white-spaces.
   In the "read+parse" procedure we could replace the "_" with 
   white-spaces again and then parse and answer the request.

2) we also could use/test the possible solution for this problem provided 
  by the mail from the link you sent. To my mind the string with the
  whitespaces is copied ok to the socket using "<<" with its full lenght. 
  The read-procedure using ">>" cutted the string at the first 
  white-space but e.g. tcp.readline(buff, 1024); should work and
  get the whole string including the whitespaces.
  We will have to test this because it is too my mind the better solution
  than "exchanging white-spaces with '_'"


>
> At this point, I cannot get  a tcpstream object to read from, directly.
>
> Suggestions/advices?
>
> Byez.
>
> <rejected>

have fun and a nice weekend,

Matt
-- 
E-mail  :  address@hidden
www     : http://www.openmosixview.com
an openMosix-cluster management GUI

If you can dream it, you can do it! 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]