tags:

views:

115

answers:

1

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