Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#11115) Unsafe use of create_server_list
Home

[Freeciv-Dev] (PR#11115) Unsafe use of create_server_list

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11115) Unsafe use of create_server_list
From: "Benedict Adamson" <badamson@xxxxxxxxxxx>
Date: Sat, 20 Nov 2004 16:47:59 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11115 >

The function create_server_list may return a NULL pointer. The 
get_meta_list function in client/gui-gtk-2.0/pages.c passes the value to 
update_server_list, which expects a non-NULL value.

In particular, it seems that a NULL value is possible if a DNS lookup of 
the meta server fails, which is very likely for a LAN without an 
Internet connection up.

This affects the latest development version and the latest beta release 
version.

Attached is a minimally tested patch.

--- vendor.freeciv.beta/client/gui-gtk-2.0/pages.c      2004-11-20 
17:15:24.000000000 +0000
+++ freeciv.PR10694-3/client/gui-gtk-2.0/pages.c        2004-11-21 
00:32:54.000000000 +0000
@@ -250,6 +250,7 @@
                               GtkListStore *store, struct server_list *list)
 {
   const gchar *host, *port;
+  assert(list);
 
   host = gtk_entry_get_text(GTK_ENTRY(network_host));
   port = gtk_entry_get_text(GTK_ENTRY(network_port));
@@ -286,9 +287,8 @@
 {
   struct server_list *server_list = create_server_list(errbuf, n_errbuf);
 
-  update_server_list(meta_selection, meta_store, server_list);
-
   if (server_list) {
+    update_server_list(meta_selection, meta_store, server_list);
     delete_server_list(server_list);
     return TRUE;
   } else {

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