changeset: 420:62b64b818030
branch: lsx
tag: tip
parent: 418:fa3702a421d0
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Thu Jun 23 20:04:50 2011 +0100
files: lsx.c
description:
lsx: check snprintf
diff -r fa3702a421d0 -r 62b64b818030 lsx.c
--- a/lsx.c Sat Jun 18 07:50:46 2011 +0100
+++ b/lsx.c Thu Jun 23 20:04:50 2011 +0100
@@ -30,10 +30,9 @@
perror(dir);
return;
}
- while((d = readdir(dp))) {
- snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name);
- if(!stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
+ while((d = readdir(dp)))
+ if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < sizeof buf
+ && !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
puts(d->d_name);
- }
closedir(dp);
}
Received on Thu Jun 23 2011 - 21:04:57 CEST
This archive was generated by hypermail 2.2.0 : Thu Jun 23 2011 - 21:12:05 CEST