about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@conformal.com>2013-06-06 10:23:54 -0400
committerJosh Rickmar <jrick@conformal.com>2013-06-06 11:14:39 -0400
commit3ae1aab215f8c40299ef82188c1f06e02f3a2abd (patch)
tree53f6ff7c9f5900ac579209cf109f70b6ce6cc719
parenteb8920525d11b2f6735f019c3ca4ee0afcea73ef (diff)
downloadxombrero-3ae1aab215f8c40299ef82188c1f06e02f3a2abd.tar.gz
Make string copies for basename calls
Linux basename(), unlike OpenBSD, takes a char * and may modify the
contents of the path.  We're previously were passing in internal
webkit data so we must make a copy of it first.
-rw-r--r--about.c6
-rw-r--r--xombrero.c17
2 files changed, 18 insertions, 5 deletions
diff --git a/about.c b/about.c
index 46d0918..fdab608 100644
--- a/about.c
+++ b/about.c
@@ -1396,6 +1396,7 @@ xtp_page_dl_row(struct tab *t, char *html, struct download *dl)
 
 	WebKitDownloadStatus	stat;
 	const gchar		*destination;
+	gchar			*d;
 	char			*status_html = NULL, *cmd_html = NULL, *new_html;
 	gdouble			progress;
 	char			cur_sz[FMT_SCALED_STRSIZE];
@@ -1472,11 +1473,12 @@ xtp_page_dl_row(struct tab *t, char *html, struct download *dl)
 	/* we might not have a destination set yet */
 	if (!destination)
 		destination = webkit_download_get_suggested_filename(dl->download);
+	d = g_strdup(destination);	/* copy for basename */
 	new_html = g_strdup_printf(
 	    "%s\n<tr><td>%s</td><td>%s</td>"
 	    "<td style='text-align:center'>%s</td></tr>\n",
-	    html, basename((char *)destination),
-	    status_html, cmd_html);
+	    html, basename(d), status_html, cmd_html);
+	g_free(d);
 	g_free(html);
 
 	if (status_html)
diff --git a/xombrero.c b/xombrero.c
index 18cc4c8..5561778 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -5118,6 +5118,7 @@ download_status_changed_cb(WebKitDownload *download, GParamSpec *spec,
 	const char		*uri;
 	char			*file = NULL;
 	char			*mime = NULL;
+	char			*destination;
 
 	if (download == NULL)
 		return;
@@ -5125,9 +5126,14 @@ download_status_changed_cb(WebKitDownload *download, GParamSpec *spec,
 	if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED)
 		return;
 
-	if (download_notifications)
+	if (download_notifications) {
+		/* because basename() takes a char * on linux */
+		destination = g_strdup(
+		    webkit_download_get_destination_uri(download));
 		show_oops(NULL, "Download of '%s' finished",
-		    basename(webkit_download_get_destination_uri(download)));
+		    basename(destination));
+		g_free(destination);
+	}
 	uri = webkit_download_get_destination_uri(download);
 	if (uri == NULL)
 		return;
@@ -5185,6 +5191,7 @@ download_start(struct tab *t, struct download *d, int flag)
 	gchar			*filename = NULL;
 	char			*uri = NULL;
 	char			*path = NULL;
+	char			*destination;
 	int			ret = TRUE;
 	int			i;
 
@@ -5254,8 +5261,12 @@ download_start(struct tab *t, struct download *d, int flag)
 
 		/* get from history */
 		g_object_ref(d->download);
+		/* because basename() takes a char * on linux */
+		destination = g_strdup(
+		    webkit_download_get_destination_uri(d->download));
 		show_oops(t, "Download of '%s' started...",
-		    basename(webkit_download_get_destination_uri(d->download)));
+		    basename(destination));
+		g_free(destination);
 	}
 
 	if (flag != XT_DL_START)
st_layers?h=main&id=2a94896bb9ebc5042afb739fe94ffcc05705a137'>^
d822d111 ^


1baa04db ^

3cc643be ^
d9ee2076 ^

4ba60f35 ^
eb917331 ^
1baa04db ^

3cc643be ^
1baa04db ^

3cc643be ^

1baa04db ^
3cc643be ^





1baa04db ^
3cc643be ^
61c021fd ^
3cc643be ^





61c021fd ^
3cc643be ^
61c021fd ^
3cc643be ^





61c021fd ^
3cc643be ^
61c021fd ^
3cc643be ^



445bc53e ^

61c021fd ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85