From 162b871682946169871db3622e156ef641c44bf2 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 18 May 2012 08:36:43 +0200 Subject: src/notify.c: Fix printf() misuse Make sure we actually copy the notification warning interval to the correct buffer instead of printing it to stdout (using an arbitrary format string). This makes sure the current warning interval is shown when editing the field and also eliminates a potential format string vulnerability. Spotted with "-Wformat-nonliteral". Signed-off-by: Lukas Fleischer --- src/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notify.c b/src/notify.c index 188d92c..3ed53bf 100644 --- a/src/notify.c +++ b/src/notify.c @@ -777,7 +777,7 @@ notify_config_bar (void) case '4': status_mesg (count_str, ""); pthread_mutex_lock (&nbar.mutex); - printf (buf, "%d", nbar.cntdwn); + snprintf (buf, BUFSIZ, "%d", nbar.cntdwn); pthread_mutex_unlock (&nbar.mutex); if (updatestring (win[STA].p, &buf, 0, 1) == 0 && is_all_digit (buf) && atoi (buf) >= 0 && atoi (buf) <= DAYINSEC) -- cgit v1.2.3-54-g00ecf From b4cefe2db9d45dfba9bfd633288a406a8ad2a4c3 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 21 Apr 2012 12:44:11 +0200 Subject: Do not localize dates in pcal exports * Do not localize the word "week" in pcal export headers. * Reset current locale before formatting dates in pcal export data. Addresses BUG#1. Signed-off-by: Lukas Fleischer --- src/io.c | 2 +- src/utils.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/io.c b/src/io.c index 8709341..21d8b42 100644 --- a/src/io.c +++ b/src/io.c @@ -323,7 +323,7 @@ pcal_export_header (FILE *stream) calendar_week_begins_on_monday () ? "Monday" : "Sunday"); (void)fprintf (stream, "# Display week number (i.e. 1-52) on every Monday\n"); - (void)fprintf (stream, "all monday in all %s %%w\n", _("Week")); + (void)fprintf (stream, "all monday in all week %%w\n"); (void)fprintf (stream, "\n"); } diff --git a/src/utils.c b/src/utils.c index b165111..0a01c2e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -488,8 +488,15 @@ date_sec2date_str (long sec, char *datefmt) void date_sec2date_fmt (long sec, const char *fmt, char *datef) { + /* TODO: Find a better way to deal with localization and strftime(). */ + char *locale_old = mem_strdup (setlocale (LC_ALL, NULL)); + setlocale (LC_ALL, "C"); + struct tm *lt = localtime ((time_t *)&sec); strftime (datef, BUFSIZ, fmt, lt); + + setlocale (LC_ALL, locale_old); + mem_free (locale_old); } /* -- cgit v1.2.3-54-g00ecf