summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2010-02-14 17:29:16 +0000
committerFrederic Culot <calcurse@culot.org>2010-02-14 17:29:16 +0000
commit7542f4a711c41f3b87f587f29e0c3032b8ffb3ea (patch)
tree87e081abc307fb2d1cc9a3ae6bf91952cea38178
parentdf75c2754a09995b686ce0865b0e02032ff7a68d (diff)
downloadcalcurse-7542f4a711c41f3b87f587f29e0c3032b8ffb3ea.tar.gz
calcurse-7542f4a711c41f3b87f587f29e0c3032b8ffb3ea.zip
Avoid a segfault when txt_max_len becomes too small. Reported by Thorsten, thanks.
-rwxr-xr-xsrc/notify.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/notify.c b/src/notify.c
index 72741ed..364b4d2 100755
--- a/src/notify.c
+++ b/src/notify.c
@@ -1,4 +1,4 @@
-/* $calcurse: notify.c,v 1.47 2009/08/17 10:04:39 culot Exp $ */
+/* $calcurse: notify.c,v 1.48 2010/02/14 17:29:16 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -268,9 +268,12 @@ notify_update_bar (void)
{
if (strlen (notify_app.txt) > txt_max_len)
{
+ int shrink_len;
+
too_long = 1;
- (void)strncpy (buf, notify_app.txt, txt_max_len - 3);
- buf[txt_max_len - 3] = '\0';
+ shrink_len = txt_max_len > 3 ? txt_max_len - 3 : 1;
+ (void)strncpy (buf, notify_app.txt, shrink_len);
+ buf[shrink_len] = '\0';
}
time_left = notify_time_left ();
if (time_left > 0)