From kde-commits Sun Dec 08 02:56:36 2002 From: Oswald Buddenhagen Date: Sun, 08 Dec 2002 02:56:36 +0000 To: kde-commits Subject: Re: kdelibs/kdoctools X-MARC-Message: https://marc.info/?l=kde-commits&m=103931628802141 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--fUYQa+Pmc3FrFX/N" --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Dec 08, 2002 at 03:47:01AM +0100, Oswald Buddenhagen wrote: > here we go ... > > + buf[9] = 55; > + snprintf(buf, 10, "0123456789"); > + if (buf[8]) ^ > + return 1; > heh, that was my test whether it actually works. too bad i forgot to revert it. :} attached is a corrected and even more paranoid version. -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. --fUYQa+Pmc3FrFX/N 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:50:42 -0000 @@ -754,6 +754,40 @@ ]) 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[10] = 'O'; + buf[9] = 'B'; + snprintf(buf, 10, "0123456789"); + if (buf[9]) + return 1; + /* extra paranoia */ + buf[9] = 'B'; + snprintf(buf, 10, "01234%s", "56789"); + if (buf[9]) + return 1; + buf[9] = 'B'; + snprintf(buf, 10, "01234%d", 56789); + if (buf[9]) + return 1; + if (buf[10] != 'O') + 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,[ /* --fUYQa+Pmc3FrFX/N--