October 02, 2004
"novice" <novice_member@pathlink.com> wrote in message news:cjgpqb$2a1t$1@digitaldaemon.com...
> >The C function sprintf() is a function with a built-in security hole (as
in,
> >potential for buffer overflows), and of course, it is still callable from
D.
> >
>
> Thanks to Vathix for point me to sprintf analog:
> char[] s = std.string.format("hello %s", var);
>
> >Or did you mean a D replacement which returns a D char[] and can never buffer-overflow?
>
> Yes.

std.string.format() does it.


October 02, 2004
"novice" <novice_member@pathlink.com> wrote in message news:cjec2m$uu3$1@digitaldaemon.com...
> But what if f2(...) is not in my sources, and declared as void f2(...) ?
> For example f2(...) is str.stdio.writef(...)
>
> Sorry for my stupidity, but
>
> void f1(char[] formatStr, ...)
> {
> writef( formatStr,_arguments,_argptr);
> }
>
> produce runtime error...

Yes, because writef expects ... arguments, not _arguments, _argptr. The two are not the same. For an example of how to do what you wish, see the source code \dmd\src\phobos\std\stdio.d.


1 2
Next ›   Last »