From 430499af09b0ba3c44ef87c83b67a834b24ac40c Mon Sep 17 00:00:00 2001 From: portix Date: Sun, 30 Sep 2012 11:36:22 +0200 Subject: Use sizeof for stack-allocated strings; fixing one possible buffer overflow --- src/local.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/local.c') diff --git a/src/local.c b/src/local.c index 9c91f8b4..64ff7424 100644 --- a/src/local.c +++ b/src/local.c @@ -129,16 +129,16 @@ local_show_directory(GList *gl, const char *path, gboolean add_to_history) { fprintf(stderr, "stat failed for %s\n", fullpath); continue; } - strftime(date, 50, "%x", localtime(&st.st_mtime)); - strftime(time, 50, "%X", localtime(&st.st_mtime)); + strftime(date, sizeof(date), "%x", localtime(&st.st_mtime)); + strftime(time, sizeof(time), "%X", localtime(&st.st_mtime)); if (st.st_size > BPGB) - snprintf(size, 50, "%.1fG", (double)st.st_size / BPGB); + snprintf(size, sizeof(size), "%.1fG", (double)st.st_size / BPGB); else if (st.st_size > BPMB) - snprintf(size, 50, "%.1fM", (double)st.st_size / BPMB); + snprintf(size, sizeof(size), "%.1fM", (double)st.st_size / BPMB); else if (st.st_size > BPKB) - snprintf(size, 50, "%.1fK", (double)st.st_size / BPKB); + snprintf(size, sizeof(size), "%.1fK", (double)st.st_size / BPKB); else - snprintf(size, 50, "%lu", st.st_size); + snprintf(size, sizeof(size), "%lu", st.st_size); char perm[11]; int bits = 0; -- cgit v1.2.3