I know I could write an interposer to watch the arguments being passed to the strncpy library call, but it seems like this should be easy to do with DTrace.
+3
A:
Here's a working variant (tested on Mac only):
#!/usr/sbin/dtrace -s
pid$target::strncpy:entry
{
printf( "%s( %X, %s, %lld )\n",
probefunc,
arg0,
copyinstr(arg1),
arg2 );
}
copyinstr
is required since the string comes from userland into the kernel.
Nikolai N Fetissov
2009-06-11 03:09:53