Mailing List archive

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

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



Marcus Metzler writes:
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.
I download tuxzap_programs-0.2.2 and I see it also uses ostringstream
and no ostrstream. However this time it's correct because there is a
copy of the buffer _after_ it is initialized.

char path[256];
ostringstream str;

[...] /* Initializing str */

strcpy(path,str.str().data());

Note : I strongly recommand you to use strncpy() instead of strcpy(),
I would replace the last line with

strncpy(path, str.str().data(), 256);

--
Nicolas Baradakis

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



Home | Main Index | Thread Index