[illumos-Developer] Webrev for bug 561: Strange characters when executing "format"

Alexey Zaytsev alexey.zaytsev at gmail.com
Fri Jul 8 13:54:55 PDT 2011


On Sat, Jul 9, 2011 at 00:41, Gary Mills <mills at cc.umanitoba.ca> wrote:
> On Fri, Jul 08, 2011 at 08:08:13AM -0700, Garrett D'Amore wrote:
>>
>>    Oh right, strncpy vs strlcpy.   Ick.  I hate the non terminating
>>    behavior of strncpy.
>
> The more I stare at the code just below my change, the more I see
> that it can't possibly work.  This is it, introduced in changeset
> 12610,5daa5746f6ae to fix Opensolaris bug #6957124:
>
>        (void) strncpy(p, inquiry.inq_vid, sizeof (inquiry.inq_vid));
>        p += sizeof (inquiry.inq_vid) - 1;
>        *p++ = '-';
>        p = strncpy(p, inquiry.inq_pid, sizeof (inquiry.inq_pid));
>        p += sizeof (inquiry.inq_pid) - 1;
>        *p++ = '-';
>        p = strncpy(p, inquiry.inq_revision, sizeof (inquiry.inq_revision));
>
> The three values in the inquiry data are space-padded in fixed-length
> fields, not null terminated.  The code to create a disk name from this
> data already exists as the get_generic_disk_name() function in the
> `format' source.  I'll be posting a new webrev soon with this function
> substituted.  Unfortunately, I can't test it, but it pretty well has
> to work.
>

I'm seeing the same problem with the IDE driver when running in kvm.
So I could test.



More information about the Developer mailing list