Bugzilla – Attachment 22897 Details for
Bug 59100
VUL-0: CVE-2004-0788: gtk+ XPM decoder issue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
pixbuftest.c
pixbuftest.c (text/plain), 2.53 KB, created by
Ludwig Nussel
on 2004-08-25 17:30:50 UTC
(
hide
)
Description:
pixbuftest.c
Filename:
MIME Type:
Creator:
Ludwig Nussel
Created:
2004-08-25 17:30:50 UTC
Size:
2.53 KB
patch
obsolete
>#if 0 ># ># run me with bash to compile ># >if [ "$1" = 1 ]; then > set -- gcc -Wall -W -g -O0 -o pixbuftest pixbuftest.c `gdk-pixbuf-config --cflags --libs` >else > set -- gcc -Wall -W -g -O0 -o pixbuftest pixbuftest.c `pkg-config gtk+-2.0 --cflags --libs` >fi >echo "$@" >exec "$@" >exit 1 >#endif > >#include <stdio.h> >#include <string.h> >#include <gtk/gtk.h> >#include <gdk-pixbuf/gdk-pixbuf.h> > >#if (GLIB_MAJOR_VERSION > 1) >#define USE_GTK2 >#endif > >#define xqf_warning(fmt, rem...) do { fprintf(stderr, fmt, ##rem); fputs("\n", stderr); } while(0) > >guchar* rgbbuf = NULL; > >void pixbuf2rgbbuf(GdkPixbuf* pixbuf) >{ > guchar* buf; > guchar* pos; > unsigned w; > unsigned h; > unsigned x; > unsigned y; > unsigned c; > unsigned rs; > > if(!pixbuf) > { > xqf_warning("NULL"); > return; > } > > w = gdk_pixbuf_get_width (pixbuf); > h = gdk_pixbuf_get_height (pixbuf); > c = gdk_pixbuf_get_n_channels (pixbuf); > rs = gdk_pixbuf_get_rowstride (pixbuf); > > printf("%dx%d@%d +%d\n", w, h, c*8, rs-w*c); > > if(c != 3 && c != 4) > { > xqf_warning("need 24 or 32 bit"); > return; > } > > pos = rgbbuf = g_new0(guchar, h*w*c); > buf = gdk_pixbuf_get_pixels (pixbuf); > if(!buf) xqf_warning("NULL"); > for(y=0; y < h; ++y) > { > for(x=0; x < w; ++x, pos+=3, buf+=c) > { > memcpy(pos, buf, 3); > } > if(x*c<rs) > { > buf += (rs - x*c); > } > } >} > >int main (int argc, char* argv[]) >{ > GtkWidget* main_window; > > gtk_init (&argc, &argv); > > if(argc < 2) > { > puts("need file"); > return 1; > } > > main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > gtk_signal_connect (GTK_OBJECT (main_window), "destroy", > GTK_SIGNAL_FUNC (gtk_main_quit), NULL); > > { > unsigned w; > unsigned h; > unsigned y; > unsigned c; > GtkWidget* preview; >#ifdef USE_GTK2 > GError* err = NULL; > GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(argv[1], &err); > if(err) > { > xqf_warning("NULL: %s", err->message); > g_error_free(err); > return 1; > } >#else > GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(argv[1]); >#endif > if(!pixbuf) > { > xqf_warning("NULL"); > return 1; > } > > w = gdk_pixbuf_get_width (pixbuf); > h = gdk_pixbuf_get_height (pixbuf); > c = gdk_pixbuf_get_n_channels (pixbuf); > > preview = gtk_preview_new(GTK_PREVIEW_COLOR); > gtk_preview_size(GTK_PREVIEW(preview), w, h); > > pixbuf2rgbbuf(pixbuf); > if(!rgbbuf) return 1; > for(y=0; y < h; ++y) > { > gtk_preview_draw_row(GTK_PREVIEW(preview), rgbbuf+y*w*c, 0, y, w); > } > gtk_container_add (GTK_CONTAINER (main_window), preview); > gtk_widget_show(preview); > } > > gtk_widget_show(main_window); > > gtk_main (); > > return 0; >} > >// vim: sw=4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 59100
:
22861
| 22897 |
22999
|
23166
|
23191