Problem in the foobar widget.



There is a bug in gnome-core 1.2.1, in panel/foobar-widget.c. 

The problem is that the return on strftime isn't being checked properly,
resulting in an undefined string being assigned to hour, e.g.

  Tuesday September29` hY@

The offending piece of code is: 

  if (das_tm->tm_mday != day) {
                  if (strftime (hour, 20, _("%A %B %d"), das_tm) == 20)
                          hour[19] = '\0';
                  gtk_tooltips_set_tip (panel_tooltips, clock_ebox, hour,
  NULL);
  
                  day = das_tm->tm_mday;
          }

This seems to assume that if the length of the formated string is longer
than the value of max (20), it will return max.  This has not been the
case since libc 4.4.1.  The test should be against 0 now instead.  

Also, I wouldn't notice this is 20 characters wasn't woefully short to fit
the specified string. Makes more sense to make it 30 :) 

Anyways, the patch follows.

Matt

--- gnome-core-1.2.1-orig/panel/foobar-widget.c Sat May  6 21:48:27 2000
+++ gnome-core-1.2.1/panel/foobar-widget.c      Tue Sep 19 17:16:33 2000
@@ -327,5 +327,5 @@
        struct tm *das_tm;
        time_t das_time;
-       char hour[20];
+       char hour[30];
 
        if (!IS_FOOBAR_WIDGET (das_global_foobar))
@@ -336,6 +336,6 @@
 
        if (das_tm->tm_mday != day) {
-               if (strftime (hour, 20, _("%A %B %d"), das_tm) == 20)
-                       hour[19] = '\0';
+               if (strftime (hour, 30, _("%A %B %d"), das_tm) == 0)
+                       hour[29] = '\0';
                gtk_tooltips_set_tip (panel_tooltips, clock_ebox, hour,
NULL);
 
@@ -343,6 +343,6 @@
        }
 
-       if (strftime (hour, 20, FOOBAR_WIDGET
(das_global_foobar)->clock_format, das_tm) == 20)
-               hour[19] = '\0';
+       if (strftime (hour, 30, FOOBAR_WIDGET
(das_global_foobar)->clock_format, das_tm) == 0)
+               hour[29] = '\0';
 
        gtk_label_set_text (GTK_LABEL (label), hour);






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]