lsx: check snprintf 88d44169
Connor Lane Smith · 2011-06-23 20:04 1 file(s) · +3 −4
lsx.c +3 −4
30 30
		perror(dir);
31 31
		return;
32 32
	}
33 -
	while((d = readdir(dp))) {
34 -
		snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name);
35 -
		if(!stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
33 +
	while((d = readdir(dp)))
34 +
		if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < sizeof buf
35 +
		&& !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
36 36
			puts(d->d_name);
37 -
	}
38 37
	closedir(dp);
39 38
}