Package: gftp Version: 2.0.18-13 Followup-For: Bug #322718 Greetings,
The bug occurs when you have an option in a site entry (.gftp/bookmarks), for example "passive_transfer" or "preserve_time". And then, you edit your bookmarks and add a new option to the site. A hash table already containing "modified params" is wrong after a realloc (see config_file.c, gftp_set_bookmark_option). See attached patch. Matthieu Crapet -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.16.19-matt Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15) Versions of packages gftp depends on: ii gftp-gtk 2.0.18-13 X/GTK+ FTP client ii gftp-text 2.0.18-13 colored FTP client using GLib gftp recommends no packages. -- no debconf information
--- config_file.c.orig 2006-06-15 04:13:30.000000000 +0200 +++ config_file.c 2006-06-15 03:56:37.000000000 +0200 @@ -1420,6 +1420,8 @@ _gftp_set_option_value (tmpconfigvar, value); else { + int i; + if (gftp_global_options_htable == NULL || (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable, key)) == NULL) @@ -1437,15 +1439,22 @@ ret = gftp_option_types[tmpconfigvar->otype].compare_function (&newconfigvar, tmpconfigvar); if (ret == 0) return; - + if (bm->local_options_hash == NULL) bm->local_options_hash = g_hash_table_new (string_hash_function, string_hash_compare); bm->num_local_options_vars++; - bm->local_options_vars = g_realloc (bm->local_options_vars, + bm->local_options_vars = g_realloc (bm->local_options_vars, sizeof (gftp_config_vars) * bm->num_local_options_vars); + /* We must rebuild the bm->local_options_hash because pointers are relocated + (remember that g_hash_table do not keep their own copies of either keys or values) */ + for (i = 0; i < bm->num_local_options_vars - 1; i++) { + g_hash_table_replace (bm->local_options_hash, bm->local_options_vars[i].key, + &bm->local_options_vars[i]); + } + memcpy (&bm->local_options_vars[bm->num_local_options_vars - 1], tmpconfigvar, sizeof (*tmpconfigvar)); _gftp_set_option_value (&bm->local_options_vars[bm->num_local_options_vars - 1], value);