Mailing List archive

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

[linux-dvb] Dangerous mix between C++ strings and C char arrays



Nicolas Baradakis writes:
 > In all the source files in the folder DVB/apps/tuxzap I can see things
 > like : 
 > 
 > 	char path[256];
 > 	ostringstream str(string(path,256)); 
 > 
 > Then the author initializes the  string `str' correctly and after that
 > he  uses the pointer  `path'. This  is wrong,  because in  the current
 > implementation  of the STL  string() makes  a copy  of `path',  so the
 > variables `str' and `path' don't share the same buffer. 
 > 
 > In result I can successfully compile the applications
 > {r,n,}tux{player,view,zap} but they aren't working and I can see a lot
 > of random characters instead of the messages. 
 > 
 > I think  it's better if the  author corrects the bugs  himself, but if
 > you ask me I can make a patch by adding some strncpy() when needed. 
 > 

The latest version of the tuxzap programs are at
http://www.metzlerbros.de
and I don't think I use contruct likes the one above.
I don't remember ever using such a contruct, maybe someone else
patched the CVS because I used to use ostrstream.

Marcus

-- 
/--------------------------------------------------------------------\
| Dr. Marcus O.C. Metzler        |                                   |
|--------------------------------|-----------------------------------|
| mocm@metzlerbros.de            | http://www.metzlerbros.de/        |
\--------------------------------------------------------------------/



-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index