lkml.org 
[lkml]   [2008]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] IDE-TAPE NULL terminate strings.
On Mon, Sep 22, 2008 at 03:56:49PM +0200, Boris Petkov wrote:
> On Mon, Sep 22, 2008 at 3:16 PM, Sergei Shtylyov
> <sshtylyov@ru.mvista.com> wrote:
> > Hello.
> >
> .. and I know why :). Those ide_tape_obj members (char fw_rev[6], vendor_id[10],
> product_id[18]) were used only once in idetape_get_inquiry_results() so I moved
> them there as local stack variables. Originally, they were kzalloc'ed as part of
> struct ide_tape_obj and now they contain stack garbage therefore the funny
> values. The simple solution would be to zero them out or:
>
>
> Does the following patch help?

Yes feel free to add my tested-by.

Only not sure whether the static is the best solution, the following
patch also works, by zeroing the memory as you suggested.

Signed-off-by: Mark de Wever <koraq@xs4all.nl>

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1bce84b..c41f5b1 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2338,7 +2338,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
{
idetape_tape_t *tape = drive->driver_data;
struct ide_atapi_pc pc;
- char fw_rev[6], vendor_id[10], product_id[18];
+ char fw_rev[6] = {'\0'}, vendor_id[10] = {'\0'}, product_id[18] = {'\0'};

idetape_create_inquiry_cmd(&pc);
if (idetape_queue_pc_tail(drive, &pc)) {
--
Regards,
Mark de Wever


\
 
 \ /
  Last update: 2008-09-22 22:47    [W:0.113 / U:5.432 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site