Commit Diff


commit - bb28f1c2f6463f1e8881c90bb17a404cf7e5c3b7
commit + f8c6e75351fd01dc58eabd367348ce79fe131193
blob - 30641668070413fbd954662660edc60a09fb2af6
blob + d844b079644dcc343610c602e3b3195153dd665c
--- fs.c
+++ fs.c
@@ -50,7 +50,6 @@ static void		 handle_update_cert(struct imsg*, size_t)
 static void		 handle_file_open(struct imsg*, size_t);
 static void		 handle_session_start(struct imsg*, size_t);
 static void		 handle_session_tab(struct imsg*, size_t);
-static void		 handle_session_tab_title(struct imsg*, size_t);
 static void		 handle_session_end(struct imsg*, size_t);
 static void		 handle_dispatch_imsg(int, short, void*);
 static int		 fs_send_ui(int, uint32_t, int, const void *, uint16_t);
@@ -95,7 +94,6 @@ static imsg_handlerfn *handlers[] = {
 	[IMSG_FILE_OPEN] = handle_file_open,
 	[IMSG_SESSION_START] = handle_session_start,
 	[IMSG_SESSION_TAB] = handle_session_tab,
-	[IMSG_SESSION_TAB_TITLE] = handle_session_tab_title,
 	[IMSG_SESSION_END] = handle_session_end,
 };
 
@@ -483,39 +481,27 @@ handle_session_start(struct imsg *imsg, size_t datalen
 static void
 handle_session_tab(struct imsg *imsg, size_t datalen)
 {
-	char		*url;
-	uint32_t	 flags;
+	struct session_tab	tab;
 
 	if (session == NULL)
 		die();
 
-	flags = imsg->hdr.peerid;
-	url = imsg->data;
-	if (datalen == 0 || url[datalen-1] != '\0')
+	if (datalen != sizeof(tab))
 		die();
-	fprintf(session, "%s", url);
 
-	if (flags & TAB_CURRENT)
+	memcpy(&tab, imsg->data, sizeof(tab));
+	if (tab.uri[sizeof(tab.uri)-1] != '\0' ||
+	    tab.title[sizeof(tab.title)-1] != '\0')
+		die();
+
+	fprintf(session, "%s", tab.uri);
+
+	if (tab.flags & TAB_CURRENT)
 		fprintf(session, " current ");
 	else
 		fprintf(session, " - ");
-}
 
-static void
-handle_session_tab_title(struct imsg *imsg, size_t datalen)
-{
-	const char	*title;
-
-	title = imsg->data;
-	if (title == NULL) {
-		datalen = 1;
-		title = "";
-	}
-
-	if (title[datalen-1] != '\0')
-		die();
-
-	fprintf(session, "%s\n", title);
+	fprintf(session, "%s\n", tab.title);
 }
 
 static void
blob - 3ad12544f8771b00c748f3ca1e27e918f773996b
blob + c1a3a0dd71323c91b35785b5108a0ecd647a46ff
--- session.c
+++ session.c
@@ -109,9 +109,8 @@ stop_tab(struct tab *tab)
 void
 save_session(void)
 {
-	struct tab	*tab;
-	char		*t;
-	int		 flags;
+	struct session_tab	 st;
+	struct tab		*tab;
 
 	if (safe_mode)
 		return;
@@ -119,15 +118,14 @@ save_session(void)
 	ui_send_fs(IMSG_SESSION_START, 0, NULL, 0);
 
 	TAILQ_FOREACH(tab, &tabshead, tabs) {
-		flags = tab->flags;
+		memset(&st, 0, sizeof(st));
+
 		if (tab == current_tab)
-			flags |= TAB_CURRENT;
+			st.flags = TAB_CURRENT;
 
-		t = tab->hist_cur->h;
-		ui_send_fs(IMSG_SESSION_TAB, flags, t, strlen(t)+1);
-
-		t = tab->buffer.page.title;
-		ui_send_fs(IMSG_SESSION_TAB_TITLE, 0, t, strlen(t)+1);
+		strlcpy(st.uri, tab->hist_cur->h, sizeof(st.uri));
+		strlcpy(st.title, tab->buffer.page.title, sizeof(st.title));
+		ui_send_fs(IMSG_SESSION_TAB, 0, &st, sizeof(st));
 	}
 
 	ui_send_fs(IMSG_SESSION_END, 0, NULL, 0);
blob - 6c4ec8569884c64061a1e3ea38634184eef8f1f7
blob + a0bd94a5f30f133c6a26a40186a686519816e0ec
--- telescope.h
+++ telescope.h
@@ -69,7 +69,6 @@ enum imsg_type {
 
 	IMSG_SESSION_START,
 	IMSG_SESSION_TAB,
-	IMSG_SESSION_TAB_TITLE,
 	IMSG_SESSION_END,
 };