Re: [PATCH] mdadm: fix a buffer overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, there are more of similar code. Let me resend a patch that fix them together. 
 
Thanks,
Song


>> On 9/7/16, 5:28 PM, "Song Liu" <songliubraving@xxxxxx> wrote:

    struct mdp_superblock_1.set_name is 32B long, but struct mdinfo.name
    is 33B long. So we need strncpy instead strcpy to avoid buffer
    overflow.
    
    Signed-off-by: Song Liu <songliubraving@xxxxxx>
    ---
     super1.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/super1.c b/super1.c
    index f3e4023..942f0d2 100644
    --- a/super1.c
    +++ b/super1.c
    @@ -1294,7 +1294,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
     			strcat(sb->set_name, ":");
     			strcat(sb->set_name, info->name);
     		} else
    -			strcpy(sb->set_name, info->name);
    +			strncpy(sb->set_name, info->name, 32);
     	} else if (strcmp(update, "devicesize") == 0 &&
     	    __le64_to_cpu(sb->super_offset) <
     	    __le64_to_cpu(sb->data_offset)) {
    -- 
    2.8.0.rc2
    
    


��.n��������+%������w��{.n�����{����w��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux