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]
To: badamson@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11115) Unsafe use of create_server_list
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Tue, 23 Nov 2004 07:36:41 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [badamson@xxxxxxxxxxx - Sun Nov 21 00:47:58 2004]:
> 
> 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.

Oops. Yes, this is a nasty NULL pointer chasing bug. Nice catch. However
your solution is not very good, because we really should clear the list
when this happens. Here is another patch that fixes the problem.

Index: client/gui-gtk-2.0/pages.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/pages.c,v
retrieving revision 1.12
diff -u -r1.12 pages.c
--- client/gui-gtk-2.0/pages.c  14 Nov 2004 19:38:56 -0000      1.12
+++ client/gui-gtk-2.0/pages.c  23 Nov 2004 15:35:41 -0000
@@ -256,6 +256,10 @@
 
   gtk_list_store_clear(store);
 
+  if (!list) {
+    return;
+  }
+
   server_list_iterate(*list, pserver) {
     GtkTreeIter it;
     gchar *row[6];

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