Bug 94940

Summary: Subscript out of range
Product: [Applications] kontact Reporter: Marcin Garski <mgarski>
Component: calendarAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Marcin Garski 2004-12-11 18:46:35 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

File kdepim/libkcal/versit/vobject.c contain writeGroup() function.

There is statement:
buf2[sizeof(buf2)] = '\0';

but char buf2[256].

Suggested resolution:
buf2[sizeof(buf2)-1] = '\0';
Comment 1 Reinhold Kainhofer 2005-02-20 16:24:42 UTC
CVS commit by kainhofe: 

Fix possible crash, indices are 0-based... Thanks to Marcin Garski.
BUG:94940


  M +1 -1      vobject.c   1.5


--- kdepim/libkcal/versit/vobject.c  #1.4:1.5
@@ -1228,5 +1228,5 @@ static void writeGroup(OFile *fp, VObjec
     while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
         strncpy(buf2,STRINGZ_VALUE_OF(o),sizeof(buf2));
-        buf2[sizeof(buf2)] = '\0';
+        buf2[sizeof(buf2)-1] = '\0';
         strncat(buf2,".",sizeof(buf2)-strlen(buf2)-1);
         strncat(buf2,buf1,sizeof(buf2)-strlen(buf2)-1);