[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] misc: Replace zero-length arrays with flexible array mem
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 1/2] misc: Replace zero-length arrays with flexible array member (automatic) |
Date: |
Wed, 4 Mar 2020 14:44:29 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 04/03/20 14:12, Philippe Mathieu-Daudé wrote:
>
> hw/scsi/spapr_vscsi.c:69:29: error: field 'iu' with variable sized type
> 'union viosrp_iu' not at the end of a struct or class is a GNU extension
> [-Werror,-Wgnu-variable-sized-type-not-at-end]
> union viosrp_iu iu;
> ^
>
> Yay we found a bug! Thanks Gustavo :)
>
> union srp_iu {
> struct srp_login_req login_req;
> struct srp_login_rsp login_rsp;
> struct srp_login_rej login_rej;
> struct srp_i_logout i_logout;
> struct srp_t_logout t_logout;
> struct srp_tsk_mgmt tsk_mgmt;
> struct srp_cmd cmd;
> struct srp_rsp rsp;
> uint8_t reserved[SRP_MAX_IU_LEN];
> };
It's variable-sized but it's okay as long as the total size doesn't
exceed SRP_MAX_IU_LEN. So it's not a bug, but I agree it's a time bomb.
Moving the field last should work, but it would still be quite
dangerous code.
Paolo
[PATCH 2/2] misc: Replace zero-length arrays with flexible array member (manual), Philippe Mathieu-Daudé, 2020/03/03
Re: [PATCH 0/2] misc: Replace zero-length arrays with flexible array member, Paolo Bonzini, 2020/03/04