Re: [PATCH] IDE-TAPE NULL terminate strings.

From: Sergei Shtylyov
Date: Sun Sep 21 2008 - 18:12:42 EST


Hello.

Mark de Wever wrote:

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1bce84b..fd87b43 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2354,6 +2354,10 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
ide_fixstring(product_id, 18, 0);
ide_fixstring(fw_rev, 6, 0);
Hm, I see that every string variable declared there has 2 extra characters, and yet the author have managed to make a mistake... these extra chars don't seem needed.

Those extra characters made me believe the intention was setting the
NULL character, therefore I used that solution in my patch.

It was wrong to call ide_fixstring() on those "long" stings without first setting their last byte to 0 -- this way that function just copied the garbage at the end of the passed unterminated strings.
I suggest that you get rid of those extra bytes as well, and use the "%.<n>s" format specifiers.

Regards,
Mark de Wever

MBR, Sergei


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/