FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Thu Jun 24, 2021 15:11



Post new topic Reply to topic  [ 2 posts ] 
bug in ntfsclone.c: badsector magic not copied properly 
Author Message

Joined: Tue Jan 01, 2013 15:46
Posts: 6
Post bug in ntfsclone.c: badsector magic not copied properly
ntfsclone tries to put a magic value at the start of bad sectors, but rescue_sector() uses the size of a pointer, not the length of the string.

Code:
        const char *badsector_magic = "BadSectoR\0";
        ...
                memmove(buff, badsector_magic, sizeof(badsector_magic));


Using an array instead of a pointer to a string constant would I think get sizeof to do what you want, if you still want to do that instead of using strcpy. Also note that memcpy would be appropriate here, because the source of the copy can't overlap with the destination.

so e.g.
Code:
        const char []badsector_magic = "BadSectoR\0";
        ...
                memcpy(buff, badsector_magic, sizeof(badsector_magic));


should work.

Anyway, mystery solved as to why grep wasn't finding BadSectoR anywhere in the output of strings -tx.


Tue Jan 01, 2013 16:00
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: bug in ntfsclone.c: badsector magic not copied properly
Hi,

Quote:
ntfsclone tries to put a magic value at the start of bad sectors, but rescue_sector() uses the size of a pointer, not the length of the string.

Good point.

Thanks,

Jean-Pierre


Tue Jan 01, 2013 23:15
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.