On Tue, May 25, 2010 at 10:23 AM, Mark Phalan <mark.pha...@sun.com> wrote:
> On Tue, 2010-05-25 at 09:36 -0400, Chad Mynhier wrote:
>>
>> OTOH, copyinstr() _does_ take a second argument that specifies a max
>> length, so the workaround you're looking for is to use that:
>>
>>   data_string = strjoin("@",
>>       copyinstr((uintptr_t)(*((uint32_t *)
>>       copyin((uintptr_t)&P->data, sizeof (uint32_t)))), *((uint32_t *)
>>       copyin((uintptr_t)&P->length, sizeof (uint32_t)))));
>>
>> copyinstr() will null-terminate the resulting string.  You can see
>> this here:  
>> http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/dtrace/dtrace.c#3174.
>>
>
> copyinstr() will work when the source is NULL terminated. It mostly
> won't be in the real-world case I'll need this for. I think my
> workaround with substr() (see other mail) should work though.
>

I'm confused as to why you think that copyinstr() won't work here.  If
you give copyinstr() a length as the second argument, it will behave
exactly like a copyin(), but it will also guarantee to null-terminate
the resulting string.  I've tested this, and it works.

Chad
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to