summaryrefslogtreecommitdiff
blob: 20bdcdfcff238650ccac0ced5c49e6007f63ad90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if the getdents struct is corrupt, strace will loop forever

--- strace/file.c
+++ strace/file.c
@@ -2414,6 +2414,10 @@ struct tcb *tcp;
 #endif /* SUNOS4 */
 		i += d->d_reclen;
 		dents++;
+		if (!d->d_reclen) {
+			fprintf(stderr, "[error: d->d_reclen == 0] ");
+			break;
+		}
 	}
 	if (!abbrev(tcp))
 		tprintf("}");
@@ -2466,6 +2470,10 @@ struct tcb * tcp;
 		}
 		i += d->d_reclen;
 		dents++;
+		if (!d->d_reclen) {
+			fprintf(stderr, "[error: d->d_reclen == 0] ");
+			break;
+		}
 	}
 	if (!abbrev(tcp))
 		tprintf("}");