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 463a45c..07e3b01 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 e877b78..6614c21 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 1dabf77..0e60ae0 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 f97481e..1635cda 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 )
                                        {