kdenetwork/ksirc
Lubos Lunak
l.lunak at suse.cz
Mon Dec 16 17:22:47 GMT 2002
On Monday 16 of December 2002 17:57, Andrew Standley-Jones wrote:
> CVS commit by asj:
>
> Make it work with 3.1 libs
No. In order to make it work with 3.1 libs, you have to update your admin/
dir. Before another one of you goes to change strlcpy back to strncpy,
because something doesn't compile, first check that you're up to date, and
then please complain to me.
And since people ask, the full story is here :
http://www.courtesan.com/todd/papers/strlcpy.html
In short, strlcpy and strlcat are what strncpy and strncat probably were
meant to be. You simply pass the total buffer size as the last argument, and
they'll take care of the rest. Both strncpy and strncat are quite poorly
designed and are easy to use incorrectly.
In order to use strlcpy/strlcat, the code has to #include <config.h>, because
most platforms don't have it, and the code also has to link to either
libkdecore or libkdefakes.
The rules for usage are simple:
1) avoid plain char* texts and use Q(C)String
or
2) always check you have enough space in buffers
or
3) use strlcpy and strlcat
That's about it.
I will now check that KDE_3_0_BRANCH and newer have the configure check and
the code in fakes, and the next person doing similar change will have to
discuss it with my bazooka >;).
>
>
> M +6 -1 iocontroller.cpp 1.47
>
>
> --- kdenetwork/ksirc/iocontroller.cpp #1.46:1.47
> @@ -75,4 +75,5 @@
>
> #include <kdebug.h>
> +#include <kdeversion.h>
> #include <kprocess.h>
> #include <kstandarddirs.h>
> @@ -249,5 +250,9 @@ void KSircIOController::stdin_write(QCSt
> }
> send_buf = new char[len];
> +#if KDE_VERSION > 310
> strlcpy(send_buf, buffer.data(), len);
> +#else
> + strncpy(send_buf, buffer.data(), len);
> +#endif
> if(proc->writeStdin(send_buf, len) == FALSE){
> kdDebug() << "Failed to write but CTS HIGH! Setting low!: " << s <<
> endl;
--
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o. e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27 tel: +420 2 9654 2373
190 00 Praha 9 fax: +420 2 9654 2374
Czech Republic http://www.suse.cz/
More information about the kde-core-devel
mailing list