From kde-commits Sun Dec 08 02:47:01 2002 From: Oswald Buddenhagen Date: Sun, 08 Dec 2002 02:47:01 +0000 To: kde-commits Subject: Re: kdelibs/kdoctools X-MARC-Message: https://marc.info/?l=kde-commits&m=103931568401898 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--YZ5djTAD1cGYuMQK" --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Dec 07, 2002 at 05:39:55PM +0100, Dirk Mueller wrote: > On Sam, 07 Dez 2002, Oswald Buddenhagen wrote: > > > ... and consequently the "-1" should go away. > > Write a configure check and commit it. > here we go ... the test checks whether literal strings, replaced strings and replaced integers are correctly truncated. this should be paranoid enough. ok? greetings -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="acinclude.m4.in.diff" Index: acinclude.m4.in =================================================================== RCS file: /home/kde/kde-common/admin/acinclude.m4.in,v retrieving revision 2.305 diff -u -r2.305 acinclude.m4.in --- acinclude.m4.in 3 Dec 2002 10:50:38 -0000 2.305 +++ acinclude.m4.in 8 Dec 2002 02:41:35 -0000 @@ -754,6 +754,37 @@ ]) AC_CHECK_FUNCS([vsnprintf snprintf]) +if test x$ac_cv_func_snprintf = xyes; then + AC_MSG_CHECKING([whether snprintf is safe]) + AC_TRY_RUN([ +#include + +int main() +{ + char buf[11]; + + buf[9] = 55; + snprintf(buf, 10, "0123456789"); + if (buf[8]) + return 1; + /* extra paranoia */ + buf[9] = 55; + snprintf(buf, 10, "01234%s", "56789"); + if (buf[9]) + return 1; + buf[9] = 55; + snprintf(buf, 10, "01234%d", 56789); + if (buf[9]) + return 1; + return 0; +} + ], [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + AC_MSG_ERROR([The snprintf() implementation in your c library +is seriously broken. Upgrade it and try again.])], + [AC_MSG_RESULT(unknown) + AC_MSG_WARN([Cannot test whether snprintf() works (cross-compile)])]) +fi AH_VERBATIM(_TRU64,[ /* --YZ5djTAD1cGYuMQK--