Skip to contentSkip to conversation

cluster/gfs2/fsck metawalk.c

Cluster-devel [email protected] 1 participant 1 message Jan 23, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-01-23 19:44:12

Modified files:
gfs2/fsck : metawalk.c

Log message:
Resolves: bz 223843 GFS2: gfs2_fsck segfaulting on corrupt extended attributes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.6&r2=1.7

gfs2/fsck/metawalk.c +4 -3
@@ -247,6 +247,7 @@
 	uint64_t *ea_data_ptr = NULL;
 	int i;
 	int error = 0;
+	uint32_t offset = (uint32_t)sizeof(struct gfs2_meta_header);
 
 	if(!pass->check_eattr_entry) {
 		return 0;
@@ -287,11 +288,11 @@
 				}
 			}
 		}
-		if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST){
-			/* FIXME: better equal the end of the block */
+		offset += be32_to_cpu(ea_hdr->ea_rec_len);
+		if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
+		   offset >= ip->i_sbd->sd_sb.sb_bsize || ea_hdr->ea_rec_len == 0){
 			break;
 		}
-		/* FIXME: be sure this doesn't go beyond the end */
 		ea_hdr_prev = ea_hdr;
 		ea_hdr = (struct gfs2_ea_header *)
 			((char *)(ea_hdr) +