From 1373441e927b5dc25dec52cb566cf06cd2a7c761 Mon Sep 17 00:00:00 2001 From: Andrey Slusar Date: Fri, 10 Feb 2006 20:57:15 +0000 Subject: [PATCH] Fix build on 4.x Reported by: pointyhat(kris) --- ftp/IglooFTP/files/patch-FTPcommands.h | 116 ------------------------- ftp/IglooFTP/files/patch-ftplist.c | 109 +++++++++++++++++++++++ ftp/IglooFTP/files/patch-main.c | 18 +++- 3 files changed, 124 insertions(+), 119 deletions(-) create mode 100644 ftp/IglooFTP/files/patch-ftplist.c diff --git a/ftp/IglooFTP/files/patch-FTPcommands.h b/ftp/IglooFTP/files/patch-FTPcommands.h index b18e9aed01cb..d972aaa62b12 100644 --- a/ftp/IglooFTP/files/patch-FTPcommands.h +++ b/ftp/IglooFTP/files/patch-FTPcommands.h @@ -123,122 +123,6 @@ colormap = gtk_widget_get_colormap (window); gdk_color_alloc (colormap, &done_color); ---- ftplist.c.orig Thu Apr 15 17:05:15 1999 -+++ ftplist.c Sat Feb 4 01:15:59 2006 -@@ -1189,6 +1189,15 @@ - IDLE_END; - CHECK_CONNEXION_VOID; - -+ /* Is it worth trying to handle this better? */ -+ -+ char msg_buf[1024]; -+ if ((strchr(filename, '/') != NULL) || (strstr(filename, "..") != NULL)) { -+ snprintf (msg_buf, sizeof(msg_buf), "Skipping non-relative filename: %s", filename); -+ error_message (msg_buf); -+ return; -+ } -+ - if (IGLOO_download (filename, filesize, filedate, NULL)) - { - char that_path[1024]; -@@ -1255,6 +1264,7 @@ - static void - perfom_recursive_command_on_selection (char recursive_command, char *optionnal_arg, char IS_TOP_DIR) - { -+ int fd = -1; - GList *selection = GTK_CLIST (clist)->selection; - gchar *filename; - gchar *fileperm; -@@ -1265,9 +1275,17 @@ - char DIR_FOUND_IN_SELECTION = FALSE; - char *current_remote_dir = strdup (this_session.cwd_dir); - -- tmpnam (tmp_filename); -- tmp = fopen (tmp_filename, "w"); -+ sprintf(tmp_filename, tmpfile_template); - -+ if ((fd = mkstemp (tmp_filename)) == -1 || (tmp = fdopen (fd, "w")) == NULL) -+ { -+ if (fd != -1) { -+ unlink(tmp_filename); -+ close(fd); -+ } -+ DEBUG("Unable to create temporary file."); -+ return; -+ } - - while (selection && (!want_abort)) - { -@@ -1710,6 +1728,7 @@ - static char - download_selection_recursive (void) - { -+ int fd = -1; - GdkColor done_color = GREYCYAN; - GdkColormap *colormap; - GList *selection = GTK_CLIST (clist)->selection; -@@ -1725,10 +1744,19 @@ - char *current_remote_dir = strdup (this_session.cwd_dir); - char current_local_dir[1024]; - -+ sprintf(tmp_filename, tmpfile_template); -+ - getcwd (current_local_dir, sizeof (current_local_dir)); - -- tmpnam (tmp_filename); -- tmp = fopen (tmp_filename, "w"); -+ if ((fd = mkstemp (tmp_filename)) == -1 || (tmp = fdopen (fd, "w")) == NULL) -+ { -+ if (fd != -1) { -+ unlink(tmp_filename); -+ close(fd); -+ } -+ DEBUG("Unable to create temporary file."); -+ return FALSE; -+ } - - colormap = gtk_widget_get_colormap (window); - gdk_color_alloc (colormap, &done_color); -@@ -1748,6 +1776,18 @@ - gtk_clist_get_text (GTK_CLIST (clist), index, 2, &filesize); - gtk_clist_get_text (GTK_CLIST (clist), index, 3, &filedate); - gtk_clist_get_text (GTK_CLIST (clist), index, 4, &fileperm); -+ -+ /* Basic sanity checks */ -+ -+ char msg_buf[1024]; -+ if ((strchr(filename, '/') != NULL) || (strstr(filename, "..") != NULL)) { -+ snprintf (msg_buf, sizeof(msg_buf), "Skipping non-relative filename: %s", filename); -+ error_message (msg_buf); -+ selection = selection->next; -+ gtk_clist_unselect_row (GTK_CLIST (clist), index, 0); -+ gtk_clist_moveto (GTK_CLIST (clist), index, 0, 0.5, 0); -+ continue; -+ } - - if (fileperm[0] != 'd') - { ---- main.c.orig Fri Feb 3 23:52:15 2006 -+++ main.c Sat Feb 4 01:23:16 2006 -@@ -109,6 +109,18 @@ - fpsetmask(0); - #endif - -+ char *td; -+ if ((td = getenv("TMPDIR")) != NULL && strlen(td) != 0) { -+ if (td[strlen(td)-1] == '/') -+ strncpy(tmpfile_template, td, strlen(td)-1); -+ else -+ strncpy(tmpfile_template, td, strlen(td)); -+ } else { -+ strcpy(tmpfile_template, "/tmp"); -+ } -+ strncat(tmpfile_template, "/", sizeof(tmpfile_template)); -+ strncat(tmpfile_template, TMPFILE_FILE, sizeof(tmpfile_template)); -+ - gtk_set_locale (); - gtk_init (&argc, &argv); - --- session.c.orig Thu Apr 15 17:05:15 1999 +++ session.c Fri Feb 3 23:20:24 2006 @@ -32,7 +32,8 @@ diff --git a/ftp/IglooFTP/files/patch-ftplist.c b/ftp/IglooFTP/files/patch-ftplist.c new file mode 100644 index 000000000000..c56d9dc1b469 --- /dev/null +++ b/ftp/IglooFTP/files/patch-ftplist.c @@ -0,0 +1,109 @@ +--- ftplist.c.orig Thu Apr 15 19:05:15 1999 ++++ ftplist.c Fri Feb 10 22:53:16 2006 +@@ -1158,6 +1158,7 @@ + int this_row = GTK_CLIST (clist)->focus_row; + char this_path[1024]; + char temp_path[1024]; ++ char msg_buf[1024]; + gchar *filename; + gchar *filesize; + gchar *filedate; +@@ -1189,6 +1190,14 @@ + IDLE_END; + CHECK_CONNEXION_VOID; + ++ /* Is it worth trying to handle this better? */ ++ ++ if ((strchr(filename, '/') != NULL) || (strstr(filename, "..") != NULL)) { ++ snprintf (msg_buf, sizeof(msg_buf), "Skipping non-relative filename: %s", filename); ++ error_message (msg_buf); ++ return; ++ } ++ + if (IGLOO_download (filename, filesize, filedate, NULL)) + { + char that_path[1024]; +@@ -1255,6 +1264,7 @@ + static void + perfom_recursive_command_on_selection (char recursive_command, char *optionnal_arg, char IS_TOP_DIR) + { ++ int fd = -1; + GList *selection = GTK_CLIST (clist)->selection; + gchar *filename; + gchar *fileperm; +@@ -1265,9 +1275,17 @@ + char DIR_FOUND_IN_SELECTION = FALSE; + char *current_remote_dir = strdup (this_session.cwd_dir); + +- tmpnam (tmp_filename); +- tmp = fopen (tmp_filename, "w"); ++ sprintf(tmp_filename, tmpfile_template); + ++ if ((fd = mkstemp (tmp_filename)) == -1 || (tmp = fdopen (fd, "w")) == NULL) ++ { ++ if (fd != -1) { ++ unlink(tmp_filename); ++ close(fd); ++ } ++ DEBUG("Unable to create temporary file."); ++ return; ++ } + + while (selection && (!want_abort)) + { +@@ -1710,6 +1728,7 @@ + static char + download_selection_recursive (void) + { ++ int fd = -1; + GdkColor done_color = GREYCYAN; + GdkColormap *colormap; + GList *selection = GTK_CLIST (clist)->selection; +@@ -1725,10 +1744,19 @@ + char *current_remote_dir = strdup (this_session.cwd_dir); + char current_local_dir[1024]; + ++ sprintf(tmp_filename, tmpfile_template); ++ + getcwd (current_local_dir, sizeof (current_local_dir)); + +- tmpnam (tmp_filename); +- tmp = fopen (tmp_filename, "w"); ++ if ((fd = mkstemp (tmp_filename)) == -1 || (tmp = fdopen (fd, "w")) == NULL) ++ { ++ if (fd != -1) { ++ unlink(tmp_filename); ++ close(fd); ++ } ++ DEBUG("Unable to create temporary file."); ++ return FALSE; ++ } + + colormap = gtk_widget_get_colormap (window); + gdk_color_alloc (colormap, &done_color); +@@ -1736,6 +1764,7 @@ + while (selection && (!xfer_abort) && (!want_abort)) + { + static GtkStyle *cell_style; ++ char msg_buf[1024]; + index = (int) selection->data; + + cell_style = gtk_clist_get_cell_style (GTK_CLIST (clist), index, 3); +@@ -1748,6 +1777,17 @@ + gtk_clist_get_text (GTK_CLIST (clist), index, 2, &filesize); + gtk_clist_get_text (GTK_CLIST (clist), index, 3, &filedate); + gtk_clist_get_text (GTK_CLIST (clist), index, 4, &fileperm); ++ ++ /* Basic sanity checks */ ++ ++ if ((strchr(filename, '/') != NULL) || (strstr(filename, "..") != NULL)) { ++ snprintf (msg_buf, sizeof(msg_buf), "Skipping non-relative filename: %s", filename); ++ error_message (msg_buf); ++ selection = selection->next; ++ gtk_clist_unselect_row (GTK_CLIST (clist), index, 0); ++ gtk_clist_moveto (GTK_CLIST (clist), index, 0, 0.5, 0); ++ continue; ++ } + + if (fileperm[0] != 'd') + { diff --git a/ftp/IglooFTP/files/patch-main.c b/ftp/IglooFTP/files/patch-main.c index dddf22599db0..93172e5900d6 100644 --- a/ftp/IglooFTP/files/patch-main.c +++ b/ftp/IglooFTP/files/patch-main.c @@ -1,5 +1,5 @@ ---- main.c.orig Thu Apr 15 20:05:15 1999 -+++ main.c Mon May 3 13:42:28 1999 +--- main.c.orig Thu Apr 15 19:05:15 1999 ++++ main.c Fri Feb 10 22:43:48 2006 @@ -20,6 +20,9 @@ #include #include @@ -10,14 +10,26 @@ #include "protos.h" -@@ -101,6 +104,10 @@ +@@ -100,7 +103,22 @@ + GtkWidget *hbox; GtkWidget *vbox1; char IS_SPAWNED = FALSE; ++ char *td; register int f; + +#ifdef __FreeBSD__ + fpsetmask(0); +#endif ++ if ((td = getenv("TMPDIR")) != NULL && strlen(td) != 0) { ++ if (td[strlen(td)-1] == '/') ++ strncpy(tmpfile_template, td, strlen(td)-1); ++ else ++ strncpy(tmpfile_template, td, strlen(td)); ++ } else { ++ strcpy(tmpfile_template, "/tmp"); ++ } ++ strncat(tmpfile_template, "/", sizeof(tmpfile_template)); ++ strncat(tmpfile_template, TMPFILE_FILE, sizeof(tmpfile_template)); gtk_set_locale (); gtk_init (&argc, &argv);