fixed buffer overrun
[uzbl-mobile] / uzbl.c
diff --git a/uzbl.c b/uzbl.c
index 278f3de..2bc212c 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -67,13 +67,13 @@ GOptionEntry entries[] =
         "Uri to load at startup (equivalent to 'set uri = URI')", "URI" },
     { "verbose",  'v', 0, G_OPTION_ARG_NONE,   &uzbl.state.verbose,
         "Whether to print all messages or just errors.", NULL },
-    { "name",     'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name, 
+    { "name",     'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name,
         "Name of the current instance (defaults to Xorg window id)", "NAME" },
-    { "config",   'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,   
+    { "config",   'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,
         "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" },
-    { "socket",   's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,   
+    { "socket",   's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
         "Socket ID", "SOCKET" },
-    { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry, 
+    { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry,
         "Set window geometry (format: WIDTHxHEIGHT+-X+-Y)", "GEOMETRY" },
     { "version",  'V', 0, G_OPTION_ARG_NONE, &uzbl.behave.print_version,
         "Print the version and exit", NULL },
@@ -119,8 +119,8 @@ const struct {
     { "status_pbar_pending", PTR_V(uzbl.gui.sbar.progress_u,        STR,  1,   update_title)},
     { "status_pbar_width",   PTR_V(uzbl.gui.sbar.progress_w,        INT,  1,   update_title)},
     { "status_background",   PTR_V(uzbl.behave.status_background,   STR,  1,   update_title)},
-    { "insert_indicator",    PTR_V(uzbl.behave.insert_indicator,    STR,  1,   update_title)},
-    { "command_indicator",   PTR_V(uzbl.behave.cmd_indicator,       STR,  1,   update_title)},
+    { "insert_indicator",    PTR_V(uzbl.behave.insert_indicator,    STR,  1,   update_indicator)},
+    { "command_indicator",   PTR_V(uzbl.behave.cmd_indicator,       STR,  1,   update_indicator)},
     { "title_format_long",   PTR_V(uzbl.behave.title_format_long,   STR,  1,   update_title)},
     { "title_format_short",  PTR_V(uzbl.behave.title_format_short,  STR,  1,   update_title)},
     { "icon",                PTR_V(uzbl.gui.icon,                   STR,  1,   set_icon)},
@@ -242,7 +242,7 @@ expand(char *s, guint recurse) {
     guint etype;
     char upto = ' ';
     char *end_simple_var = "^°!\"§$%&/()=?'`'+~*'#-.:,;@<>| \\{}[]¹²³¼½";
-    char str_end[2];
+    char str_end[3];
     char ret[4096];
     char *vend = NULL;
     GError *err = NULL;
@@ -477,7 +477,6 @@ clean_up(void) {
     g_free(uzbl.state.keycmd);
     g_hash_table_destroy(uzbl.bindings);
     g_hash_table_destroy(uzbl.behave.commands);
-    g_scanner_destroy(uzbl.scan);
 }
 
 /* used for html_mode_timeout
@@ -635,7 +634,7 @@ cmd_set_geometry() {
         if(uzbl.state.verbose)
             printf("Error in geometry string: %s\n", uzbl.gui.geometry);
     }
-    /* update geometry var with the actual geometry 
+    /* update geometry var with the actual geometry
        this is necessary as some WMs don't seem to honour
        the above setting and we don't want to end up with
        wrong geometry information
@@ -915,6 +914,12 @@ set_mode_indicator() {
 }
 
 void
+update_indicator() {
+  set_mode_indicator();
+  update_title();
+}
+
+void
 set_insert_mode(gboolean mode) {
     uzbl.behave.insert_mode = mode;
     set_mode_indicator();
@@ -1695,7 +1700,7 @@ set_var_value(gchar *name, gchar *val) {
     char *buf = NULL;
 
     if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
-        if(!c->writeable) return TRUE;
+        if(!c->writeable) return FALSE;
 
         /* check for the variable type */
         if (c->type == TYPE_STR) {
@@ -2057,8 +2062,8 @@ key_press_cb (GtkWidget* window, GdkEventKey* event)
         return TRUE;
     }
 
-    if (uzbl.behave.insert_mode && 
-        ( ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) || 
+    if (uzbl.behave.insert_mode &&
+        ( ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) ||
           (!uzbl.behave.modmask)
         )
        )
@@ -2653,7 +2658,7 @@ initialize(int argc, char *argv[]) {
     if(setup_signal(SIGALRM, catch_alrm) == SIG_ERR)
         fprintf(stderr, "uzbl: error hooking SIGALARM\n");
 
-    uzbl.gui.sbar.progress_s = g_strdup("=");
+    uzbl.gui.sbar.progress_s = g_strdup("="); //TODO: move these to config.h
     uzbl.gui.sbar.progress_u = g_strdup("·");
     uzbl.gui.sbar.progress_w = 10;
 
@@ -2731,6 +2736,8 @@ main (int argc, char* argv[]) {
         retreive_geometry();
 
     gchar *uri_override = (uzbl.state.uri ? g_strdup(uzbl.state.uri) : NULL);
+    if (argc > 1 && !uzbl.state.uri)
+        uri_override = g_strdup(argv[1]);
     gboolean verbose_override = uzbl.state.verbose;
 
     settings_init ();