1999-11-01 Pavel Machek <pavel@ucw.cz>

* make_thumb.c: close symlink hole

       * *.c: add return_val_if_fail, it is better than crashing. Sorry
       about that *image = NULL, but gcc should be able to optimize
       out in non-debugging case.
This commit is contained in:
Pavel Machek 1999-11-01 16:30:49 +00:00
parent ec8299fa53
commit 82b8ed4aa5
4 changed files with 33 additions and 23 deletions

View File

@ -1,3 +1,11 @@
1999-11-01 Pavel Machek <pavel@ucw.cz>
* make_thumb.c: close symlink hole
* *.c: add return_val_if_fail, it is better than crashing. Sorry
about that *image = NULL, but gcc should be able to optimize it
out in non-debugging case.
1999-10-27 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop-init.c (desktop_init_at): Put an equal sign between the

View File

@ -688,6 +688,10 @@ gtk_dtree_load_pixmap (char *pix[], GdkPixmap **pixmap, GdkBitmap **bitmap)
g_assert (bitmap);
image = gdk_imlib_create_image_from_xpm_data (pix);
*pixmap = NULL;
*bitmap = NULL;
g_return_if_fail(image);
gdk_imlib_render (image, image->rgb_width, image->rgb_height);
*pixmap = gdk_imlib_move_image (image);
*bitmap = gdk_imlib_move_mask (image);

View File

@ -19,7 +19,12 @@
GtkWidget *
get_gtk_widget (Widget_Item *p)
{
GtkWidget *w = GTK_WIDGET (p->widget->wdata);
GtkWidget *w;
g_return_val_if_fail(p, NULL);
g_return_val_if_fail(p->widget, NULL);
w = GTK_WIDGET (p->widget->wdata);
if (GNOME_IS_ENTRY (w))
return (gnome_entry_gtk_entry ((GnomeEntry *)(w)));

View File

@ -1,29 +1,15 @@
/*
* What is this good for? Who wrote it and when?
*/
#include <config.h>
#include <gnome.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
char *tmp_dir, *secure;
static void
get_temp_dir (void)
{
int i = 5; /* 5 attempts */
static char name [100];
do {
strcpy (name, "/tmp/.thumbXXXXXX");
tmp_dir = mktemp (name);
if (mkdir (tmp_dir, 0700) == 0){
secure = g_concat_dir_and_file (tmp_dir, "thumb.png");
return;
}
} while (i--);
}
static void
put_in_metadata (char *dest, char *png_file)
put_in_metadata (char *dest, char *png_file, char *secure)
{
int f;
struct stat buf;
@ -91,14 +77,21 @@ int
main (int argc, char *argv [])
{
int i;
char *secure;
gnome_init ("test", "test", argc, argv);
get_temp_dir ();
secure = tempnam (NULL, "makethumb");
i = open (secure, O_RDWR | O_CREAT | O_EXCL, 0600);
if (i == -1) {
printf( "Someone is playing /tmp games with us\n" );
exit(2);
}
close(i);
for (i = 1; i < argc; i++)
make_thumbnail (argv [i]);
make_thumbnail (argv [i], secure);
unlink (secure);
rmdir (tmp_dir);
return 0;
}