mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-03 18:20:25 +02:00 
			
		
		
		
	udf: Get rid of 0-length arrays in struct fileIdentDesc
Get rid of 0-length arrays in struct fileIdentDesc. This requires a bit of cleaning up as the second variable length array in this structure is often used and the code abuses the fact that the first two arrays have the same type and offset in struct fileIdentDesc. Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
		
							parent
							
								
									b3c8c9801e
								
							
						
					
					
						commit
						979a6e28dd
					
				
					 5 changed files with 16 additions and 15 deletions
				
			
		| 
						 | 
					@ -35,7 +35,6 @@
 | 
				
			||||||
#include "udf_i.h"
 | 
					#include "udf_i.h"
 | 
				
			||||||
#include "udf_sb.h"
 | 
					#include "udf_sb.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
static int udf_readdir(struct file *file, struct dir_context *ctx)
 | 
					static int udf_readdir(struct file *file, struct dir_context *ctx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct inode *dir = file_inode(file);
 | 
						struct inode *dir = file_inode(file);
 | 
				
			||||||
| 
						 | 
					@ -135,7 +134,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
 | 
				
			||||||
		lfi = cfi.lengthFileIdent;
 | 
							lfi = cfi.lengthFileIdent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (fibh.sbh == fibh.ebh) {
 | 
							if (fibh.sbh == fibh.ebh) {
 | 
				
			||||||
			nameptr = fi->fileIdent + liu;
 | 
								nameptr = udf_get_fi_ident(fi);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			int poffset;	/* Unpaded ending offset */
 | 
								int poffset;	/* Unpaded ending offset */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -153,7 +152,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				nameptr = copy_name;
 | 
									nameptr = copy_name;
 | 
				
			||||||
				memcpy(nameptr, fi->fileIdent + liu,
 | 
									memcpy(nameptr, udf_get_fi_ident(fi),
 | 
				
			||||||
				       lfi - poffset);
 | 
									       lfi - poffset);
 | 
				
			||||||
				memcpy(nameptr + lfi - poffset,
 | 
									memcpy(nameptr + lfi - poffset,
 | 
				
			||||||
				       fibh.ebh->b_data, poffset);
 | 
									       fibh.ebh->b_data, poffset);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -471,9 +471,9 @@ struct fileIdentDesc {
 | 
				
			||||||
	uint8_t		lengthFileIdent;
 | 
						uint8_t		lengthFileIdent;
 | 
				
			||||||
	struct long_ad	icb;
 | 
						struct long_ad	icb;
 | 
				
			||||||
	__le16		lengthOfImpUse;
 | 
						__le16		lengthOfImpUse;
 | 
				
			||||||
	uint8_t		impUse[0];
 | 
						uint8_t		impUse[];
 | 
				
			||||||
	uint8_t		fileIdent[0];
 | 
						/* uint8_t	fileIdent[]; */
 | 
				
			||||||
	uint8_t		padding[0];
 | 
						/* uint8_t	padding[]; */
 | 
				
			||||||
} __packed;
 | 
					} __packed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* File Characteristics (ECMA 167r3 4/14.4.3) */
 | 
					/* File Characteristics (ECMA 167r3 4/14.4.3) */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -390,8 +390,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
 | 
				
			||||||
		dfibh.eoffset += (sfibh.eoffset - sfibh.soffset);
 | 
							dfibh.eoffset += (sfibh.eoffset - sfibh.soffset);
 | 
				
			||||||
		dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset);
 | 
							dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset);
 | 
				
			||||||
		if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse,
 | 
							if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse,
 | 
				
			||||||
				 sfi->fileIdent +
 | 
									 udf_get_fi_ident(sfi))) {
 | 
				
			||||||
					le16_to_cpu(sfi->lengthOfImpUse))) {
 | 
					 | 
				
			||||||
			iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
 | 
								iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
 | 
				
			||||||
			brelse(dbh);
 | 
								brelse(dbh);
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,12 +74,11 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (fileident) {
 | 
						if (fileident) {
 | 
				
			||||||
		if (adinicb || (offset + lfi < 0)) {
 | 
							if (adinicb || (offset + lfi < 0)) {
 | 
				
			||||||
			memcpy((uint8_t *)sfi->fileIdent + liu, fileident, lfi);
 | 
								memcpy(udf_get_fi_ident(sfi), fileident, lfi);
 | 
				
			||||||
		} else if (offset >= 0) {
 | 
							} else if (offset >= 0) {
 | 
				
			||||||
			memcpy(fibh->ebh->b_data + offset, fileident, lfi);
 | 
								memcpy(fibh->ebh->b_data + offset, fileident, lfi);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			memcpy((uint8_t *)sfi->fileIdent + liu, fileident,
 | 
								memcpy(udf_get_fi_ident(sfi), fileident, -offset);
 | 
				
			||||||
				-offset);
 | 
					 | 
				
			||||||
			memcpy(fibh->ebh->b_data, fileident - offset,
 | 
								memcpy(fibh->ebh->b_data, fileident - offset,
 | 
				
			||||||
				lfi + offset);
 | 
									lfi + offset);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -88,11 +87,11 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
 | 
				
			||||||
	offset += lfi;
 | 
						offset += lfi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (adinicb || (offset + padlen < 0)) {
 | 
						if (adinicb || (offset + padlen < 0)) {
 | 
				
			||||||
		memset((uint8_t *)sfi->padding + liu + lfi, 0x00, padlen);
 | 
							memset(udf_get_fi_ident(sfi) + lfi, 0x00, padlen);
 | 
				
			||||||
	} else if (offset >= 0) {
 | 
						} else if (offset >= 0) {
 | 
				
			||||||
		memset(fibh->ebh->b_data + offset, 0x00, padlen);
 | 
							memset(fibh->ebh->b_data + offset, 0x00, padlen);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		memset((uint8_t *)sfi->padding + liu + lfi, 0x00, -offset);
 | 
							memset(udf_get_fi_ident(sfi) + lfi, 0x00, -offset);
 | 
				
			||||||
		memset(fibh->ebh->b_data, 0x00, padlen + offset);
 | 
							memset(fibh->ebh->b_data, 0x00, padlen + offset);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -226,7 +225,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
 | 
				
			||||||
		lfi = cfi->lengthFileIdent;
 | 
							lfi = cfi->lengthFileIdent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (fibh->sbh == fibh->ebh) {
 | 
							if (fibh->sbh == fibh->ebh) {
 | 
				
			||||||
			nameptr = fi->fileIdent + liu;
 | 
								nameptr = udf_get_fi_ident(fi);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			int poffset;	/* Unpaded ending offset */
 | 
								int poffset;	/* Unpaded ending offset */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -246,7 +245,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				nameptr = copy_name;
 | 
									nameptr = copy_name;
 | 
				
			||||||
				memcpy(nameptr, fi->fileIdent + liu,
 | 
									memcpy(nameptr, udf_get_fi_ident(fi),
 | 
				
			||||||
					lfi - poffset);
 | 
										lfi - poffset);
 | 
				
			||||||
				memcpy(nameptr + lfi - poffset,
 | 
									memcpy(nameptr + lfi - poffset,
 | 
				
			||||||
					fibh->ebh->b_data, poffset);
 | 
										fibh->ebh->b_data, poffset);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -130,6 +130,10 @@ static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi)
 | 
				
			||||||
		le16_to_cpu(cfi->lengthOfImpUse) + cfi->lengthFileIdent,
 | 
							le16_to_cpu(cfi->lengthOfImpUse) + cfi->lengthFileIdent,
 | 
				
			||||||
		UDF_NAME_PAD);
 | 
							UDF_NAME_PAD);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					static inline uint8_t *udf_get_fi_ident(struct fileIdentDesc *fi)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ((uint8_t *)(fi + 1)) + le16_to_cpu(fi->lengthOfImpUse);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* file.c */
 | 
					/* file.c */
 | 
				
			||||||
extern long udf_ioctl(struct file *, unsigned int, unsigned long);
 | 
					extern long udf_ioctl(struct file *, unsigned int, unsigned long);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue