2005-11-06 [colin] 1.9.99cvs13
authorColin Leroy <colin@colino.net>
Sun, 6 Nov 2005 18:59:04 +0000 (18:59 +0000)
committerColin Leroy <colin@colino.net>
Sun, 6 Nov 2005 18:59:04 +0000 (18:59 +0000)
* src/ldif.c
Fix ldif_get_line() that returned empty strings
(Didn't understand why). Also fix a possible
buffer overflow.

ChangeLog
PATCHSETS
configure.ac
src/ldif.c

index 463a45cfeb4d6cab8ffb773c9a0604ddda92b84b..07e3b01022312b78c23a8330207d48a46d5d84b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-11-06 [colin]     1.9.99cvs13
+
+       * src/ldif.c
+               Fix ldif_get_line() that returned empty strings
+               (Didn't understand why). Also fix a possible
+               buffer overflow.
+
 2005-11-06 [wwp]       1.9.99cvs12
 
        * src/textview.c
index e877b78edb6ca7c835b62bb1259261cbd58b10d7..6614c21a4047f6add81ba4582a319750240ca1b4 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.4.2.22 -r 1.4.2.23 src/gtk/about.c;  ) > 1.9.99cvs10.patchset
 ( cvs diff -u -r 1.4.2.23 -r 1.4.2.24 src/gtk/about.c;  ) > 1.9.99cvs11.patchset
 ( cvs diff -u -r 1.96.2.82 -r 1.96.2.83 src/textview.c;  cvs diff -u -r 1.4.2.24 -r 1.4.2.25 src/gtk/about.c;  cvs diff -u -r 1.5.2.16 -r 1.5.2.17 src/gtk/gtkutils.c;  cvs diff -u -r 1.4.2.14 -r 1.4.2.15 src/gtk/gtkutils.h;  ) > 1.9.99cvs12.patchset
+( cvs diff -u -r 1.12.2.4 -r 1.12.2.5 src/ldif.c;  ) > 1.9.99cvs13.patchset
index 1dabf77448ed9713f48be2a2dc7a1e32e7288487..0e60ae04a5d3053d4e26051e22f90c69d0d59ffb 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=99
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=12
+EXTRA_VERSION=13
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index f97481e1589e2f009b4ef620177f17c48c5a232f..1635cdaaa36093bbe18195757188872a9fe21b10 100644 (file)
@@ -306,26 +306,28 @@ static void ldif_close_file( LdifFile *ldifFile ) {
 static gchar *ldif_get_line( LdifFile *ldifFile ) {
        gchar buf[ LDIFBUFSIZE ];
        gint ch;
-       gchar *ptr;
+       int i = 0;
 
-       if( feof( ldifFile->file ) ) return NULL;
+       if( feof( ldifFile->file ) ) 
+               return NULL;
 
-       ptr = buf;
-       while( TRUE ) {
-               *ptr = '\0';
+       while( i < LDIFBUFSIZE-1 ) {
                ch = fgetc( ldifFile->file );
                if( ch == '\0' || ch == EOF ) {
-                       if( *buf == '\0' ) return NULL;
+                       if( i == 0 ) return NULL;
                        break;
                }
 #if HAVE_DOSISH_SYSTEM
 #else
-               if( ch == '\r' ) continue;
+               if( ch == '\r' ) 
+                       continue;
 #endif
-               if( ch == '\n' ) break;
-               *ptr = ch;
-               ptr++;
+               if( ch == '\n' ) 
+                       break;
+               buf[i] = ch;
+               i++;
        }
+       buf[i] = '\0';
 
        /* Return a copy of buffer */
        return g_strdup( buf );
@@ -908,7 +910,6 @@ static void ldif_read_tag_list( LdifFile *ldifFile ) {
        /* Process file */
        while( ! flagEOF ) {
                gchar *line = ldif_get_line( ldifFile );
-
                posCur = ftell( ldifFile->file );
                if( ldifFile->cbProgress ) {
                        /* Call progress indicator */
@@ -948,6 +949,7 @@ static void ldif_read_tag_list( LdifFile *ldifFile ) {
                                if( tagName ) {
                                        /* Add tag to list */
                                        listTags = g_slist_append( listTags, tagName );
+
                                        if( g_utf8_collate(
                                                tagName, LDIF_TAG_EMAIL ) == 0 )
                                        {