gnokii-users
[Top][All Lists]
Advanced

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

several bugs in 'xgnokii' contact handling, fixed


From: Peter Grandi
Subject: several bugs in 'xgnokii' contact handling, fixed
Date: Fri, 07 May 2004 19:49:18 +0100

I have been using 'xgnokii' for a long while, and then stopped because I
was having trouble editing contacts, the most important function to me.

The trouble was that editing an entry resulted it in being moved from
the SIM to the phone memory.

I have finally spent some time debugging it, and I have found the reason
for the issue, and fixed it, and found several similar issues. It is
just a number of cases of sloppy programming, but it is amazing they
have not been fixed until now.

The main problem is that contact list entry records have two fixed size
fields, 'name' and 'number', and they have different sizes, but rather
operations on one use the maximum size defined for the other. Here is a
patch relative to 'gnokii-20040506':

------------------------------------------------------------------------
diff -r -u gnokii-20040506/xgnokii/xgnokii.c 
gnokii-20040506_sabi/xgnokii/xgnokii.c
--- gnokii-20040506/xgnokii/xgnokii.c   2004-05-06 16:02:48.000000000 +0100
+++ gnokii-20040506_sabi/xgnokii/xgnokii.c      2004-05-07 19:14:04.000000000 
+0100
@@ -2328,7 +2328,7 @@
        xgnokiiConfig.xgnokiidir = DefaultXGnokiiDir;
 #endif
        max_phonebook_number_length = max_phonebook_sim_number_length =
-           GN_PHONEBOOK_NAME_MAX_LENGTH;
+           GN_PHONEBOOK_NUMBER_MAX_LENGTH;
 
        xgnokiiConfig.callerGroups[0] = xgnokiiConfig.callerGroups[1] =
            xgnokiiConfig.callerGroups[2] = xgnokiiConfig.callerGroups[3] =
diff -r -u gnokii-20040506/xgnokii/xgnokii_contacts.c 
gnokii-20040506_sabi/xgnokii/xgnokii_contacts.c
--- gnokii-20040506/xgnokii/xgnokii_contacts.c  2004-05-06 16:02:49.000000000 
+0100
+++ gnokii-20040506_sabi/xgnokii/xgnokii_contacts.c     2004-05-07 
19:16:43.000000000 +0100
@@ -374,7 +374,7 @@
                        strncpy(new_entry->entry.number,
                                gtk_entry_get_text(GTK_ENTRY(((EditEntryData *) 
data)->number)),
                                max_phonebook_sim_number_length);
-                       new_entry->entry.name[max_phonebook_sim_number_length] 
= '\0';
+                       
new_entry->entry.number[max_phonebook_sim_number_length] = '\0';
                }
 
                new_entry->entry.caller_group = ((EditEntryData *) 
data)->newGroup;
@@ -397,8 +397,7 @@
                        strncpy(current_entry->entry.name,
                                gtk_entry_get_text(GTK_ENTRY(((EditEntryData *) 
data)->name)),
                                max_phonebook_name_length);
-                       current_entry->entry.name[max_phonebook_name_length] =
-                           '\0';
+                       current_entry->entry.name[max_phonebook_name_length] = 
'\0';
 
                        if (phoneMonitor.supported & PM_EXTPBK) {
 
@@ -407,8 +406,7 @@
                                        gtk_entry_get_text(GTK_ENTRY
                                                           (((EditEntryData *) 
data)->number)),
                                        max_phonebook_number_length);
-                               current_entry->entry.
-                                   name[max_phonebook_number_length] = '\0';
+                               
current_entry->entry.number[max_phonebook_number_length] = '\0';
                        }
                /* Memory type not changed, SIM memory */
                } else {
@@ -438,7 +436,7 @@
                                strncpy(current_entry->entry.number,
                                        
gtk_entry_get_text(GTK_ENTRY(((EditEntryData *) data)->number)), 
                                        max_phonebook_sim_number_length);
-                               
current_entry->entry.name[max_phonebook_sim_number_length] = '\0';
+                               
current_entry->entry.number[max_phonebook_sim_number_length] = '\0';
                        }
                }
 
@@ -447,9 +445,9 @@
                current_entry->status = E_Changed;
 
                if (current_entry->entry.memory_type == GN_MT_ME)
-                       statusInfo.ch_ME = 1;
+                       statusInfo.ch_ME = 1, statusInfo.ch_SM = 0;
                else
-                       statusInfo.ch_SM = 1;
+                       statusInfo.ch_ME = 0, statusInfo.ch_SM = 1;
        }
 
        gtk_widget_hide(GTK_WIDGET(((EditEntryData *) data)->dialog));
@@ -550,7 +548,7 @@
                        strncpy(entry->entry.number,
                                gtk_entry_get_text(GTK_ENTRY(((EditEntryData *) 
data)->number)),
                                max_phonebook_number_length);
-                       entry->entry.name[max_phonebook_number_length] = '\0';
+                       entry->entry.number[max_phonebook_number_length] = '\0';
                }
 
                entry->entry.caller_group = ((EditEntryData *) data)->newGroup;
@@ -584,7 +582,7 @@
                        strncpy(entry->entry.number,
                                gtk_entry_get_text(GTK_ENTRY(((EditEntryData *) 
data)->number)),
                                max_phonebook_sim_number_length);
-                       entry->entry.name[max_phonebook_sim_number_length] = 
'\0';
+                       entry->entry.number[max_phonebook_sim_number_length] = 
'\0';
                }
 
                entry->entry.caller_group = ((EditEntryData *) data)->newGroup;
@@ -597,8 +595,7 @@
                        strncpy(((EditEntryData *) data)->pbEntry->entry.name,
                                gtk_entry_get_text(GTK_ENTRY(((EditEntryData *) 
data)->name)),
                                max_phonebook_name_length);
-                       ((EditEntryData *) 
data)->pbEntry->entry.name[max_phonebook_name_length] =
-                           '\0';
+                       ((EditEntryData *) 
data)->pbEntry->entry.name[max_phonebook_name_length] = '\0';
 
                        if (phoneMonitor.supported & PM_EXTPBK) {
                        } else {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]