1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-19 19:59:43 +00:00

Fix build on 4.x

Reported by:	pointyhat(kris)
This commit is contained in:
Andrey Slusar 2006-02-10 20:57:15 +00:00
parent 10397927f6
commit 1373441e92
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=155674
3 changed files with 124 additions and 119 deletions

View File

@ -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 @@

View File

@ -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')
{

View File

@ -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 <stdlib.h>
#include <unistd.h>
@ -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);