This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] tftp.h: rework layout to work with fortification


Mike Frysinger <vapier@gentoo.org> writes:

> diff --git a/inet/arpa/tftp.h b/inet/arpa/tftp.h
> index 21b0559..f655e95 100644
> --- a/inet/arpa/tftp.h
> +++ b/inet/arpa/tftp.h
> @@ -49,16 +49,17 @@
>  struct	tftphdr {
>  	short	th_opcode;			/* packet type */
>  	union {
> -		unsigned short	tu_block;	/* block # */
> -		short	tu_code;		/* error code */
> -		char	tu_stuff[1];		/* request packet stuff */
> -	} __attribute__ ((__packed__)) th_u;
> -	char	th_data[1];			/* data or error string */
> +		struct {
> +			union {
> +				unsigned short	th_block;	/* block # */
> +				short	th_code;		/* error code */
> +			};
> +			char th_data[0];	/* data or error string */
> +		};
> +		char	th_stuff[0];		/* request packet stuff */
> +	} __attribute__ ((__packed__));
>  } __attribute__ ((__packed__));

I wonder what's the use of packing here.  There should be no padding,
each field has at most short alignment.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]