--- Begin Message ---
Package: xbubble
Version: 0.5.11.2-2
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu jaunty ubuntu-patch
Hi,
In Ubuntu we turn on various compiler flags by default, meaning that
there more problems in code cause build failures. Your package was
one that failed due to these compiler flags.
The attached patch adds some more checking of return values of
functions calls, please consider applying it.
Thanks,
James
diff -u xbubble-0.5.11.2/debian/changelog xbubble-0.5.11.2/debian/changelog
only in patch2:
unchanged:
--- xbubble-0.5.11.2.orig/src/loadpng.c
+++ xbubble-0.5.11.2/src/loadpng.c
@@ -18,6 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
@@ -43,7 +44,8 @@
FILE *fd;
unsigned char *data;
unsigned char header[8];
- int bit_depth, color_type, i;
+ unsigned char *header_ptr;
+ int bit_depth, color_type, i, bytes_to_read, bytes_read;
png_uint_32 png_width, png_height, rowbytes;
png_structp png_ptr;
png_infop info_ptr;
@@ -55,7 +57,22 @@
return NULL;
}
/* ensure that we opened a PNG file */
- fread( header, 1, 8, fd );
+ bytes_to_read = 8;
+ header_ptr = header;
+ do {
+ bytes_read = fread( header_ptr, 1, bytes_to_read, fd );
+ if (bytes_read == bytes_to_read)
+ break;
+ if (bytes_read >= 0) {
+ bytes_to_read -= bytes_read;
+ header_ptr += bytes_read;
+ }
+ } while (bytes_read >= 0 || errno == EINTR);
+ if (bytes_read == 0) {
+ fclose(fd);
+ fprintf(stderr,_("Error reading from %s.\n"), file);
+ return NULL;
+ }
if ( ! png_check_sig( header, 8 ) ) {
fclose(fd);
fprintf(stderr,_("File %s does not have a valid PNG signature.\n"), file);
only in patch2:
unchanged:
--- xbubble-0.5.11.2.orig/src/init.c
+++ xbubble-0.5.11.2/src/init.c
@@ -97,7 +97,8 @@
path_max = 4096;
#endif
abs_data_dir = (char *) xmalloc( path_max * sizeof(char));
- realpath( data_dir, abs_data_dir );
+ if (!realpath( data_dir, abs_data_dir ))
+ return NULL;
offset = strlen(abs_data_dir);
if ( offset > 1024-128 )
offset = 1024-128;
@@ -119,8 +120,9 @@
}
-static void load_levels( const char * file ) {
+static void load_levels( const char * file_path ) {
FILE *fd;
+ char * file;
char line[128];
unsigned char r[8];
int i, cell = 0;
@@ -129,7 +131,11 @@
int color, parse_error = 0;
nb_levels = 0;
- file = data_file(file, 0);
+ file = data_file(file_path, 0);
+ if ( file == NULL ) {
+ warn( _("cannot open levels file %s."), file_path);
+ return;
+ }
fd = fopen( file, "r" );
if ( fd == NULL ) {
@@ -232,6 +238,7 @@
static XFontStruct * load_font( int pixel_size ) {
XFontStruct * xfont;
+ char * font_path;
char name[128];
int i;
static int added_font_path = 0;
@@ -245,7 +252,10 @@
}
/* let's see if we can supply a font */
if ( ! added_font_path ) {
- add_font_path(data_file("",0));
+ font_path = data_file("", 0);
+ if ( font_path == NULL )
+ fail( _("couldn't determine path to load font !") );
+ add_font_path(font_path);
added_font_path = 1;
}
sprintf( name, SUPPLIED_FONT, pixel_size );
@@ -276,8 +286,13 @@
RgbaImage ri1;
RgbaImage ri2;
Frame frame = (Frame) xmalloc( sizeof( struct _Frame ));
+ char * png_file;
- ri1 = create_rgba_image_from_png_file(data_file(file,1));
+ png_file = data_file(file, 1);
+ if ( png_file == NULL ) {
+ fail(_("Couldn't get file to load frame from"));
+ }
+ ri1 = create_rgba_image_from_png_file(png_file);
/* ri2 = ( zoom < 1.0 )? scale_rgba_image( ri1, zoom, zoom ) : ri1; */
ri2 = scale_rgba_image( ri1, zoom, zoom ) ;
pmask = ( ri2->has_alpha )? &mask : NULL;
@@ -322,11 +337,16 @@
char line[128];
char framename[128];
FILE *fd;
+ char * animation_file;
/* open animation description file */
- fd = fopen( data_file(filename,1), "r" );
+ animation_file = data_file(filename,1);
+ if ( animation_file == NULL ) {
+ fail(_("couldn't get file to load animation from"));
+ }
+ fd = fopen( animation_file, "r" );
if ( fd == NULL )
- fail( _("cannot open animation file %s."), data_file(filename,1) );
+ fail( _("cannot open animation file %s."), animation_file );
/* count frames */
while ( fgets( line, 128, fd ) != NULL ) {
@@ -362,7 +382,13 @@
static void load_scaled_image( const char *file, Pixmap *pix, Pixmap *mask, double zoom ) {
RgbaImage ri1;
RgbaImage ri2;
- ri1 = create_rgba_image_from_png_file(data_file(file,1));
+ char * png_file;
+
+ png_file = data_file(file, 1);
+ if ( png_file == NULL ) {
+ fail(_("Couldn't load file to scale image"));
+ }
+ ri1 = create_rgba_image_from_png_file(png_file);
ri2 = ( zoom < 1.0 )? scale_rgba_image( ri1, zoom, zoom ) : ri1;
create_pixmaps_from_rgba_image( ri2, pix, mask );
delete_rgba_image(ri1);
@@ -390,8 +416,13 @@
Pixmap mask;
Frame frame;
int i;
+ char * canon_data_file;
- ri2 = create_rgba_image_from_png_file(data_file("canon.png",1));
+ canon_data_file = data_file("canon.png",1);
+ if ( canon_data_file == NULL ) {
+ fail(_("Couldn't load file for canon information"));
+ }
+ ri2 = create_rgba_image_from_png_file(canon_data_file);
ri2->hotx = CANON_CX;
ri2->hoty = CANON_CY;
ri = scale_rgba_image( ri2, zoom, zoom );
@@ -503,6 +534,9 @@
/* bubble animation */
dir = data_file("./",1);
+ if ( dir == NULL ) {
+ fail(_("couldn't get dir for loading bubble"));
+ }
n = scandir(dir, &namelist, diren_select_bubbles , alphasort);
if (n < 0) fail(_("Error while scanning %s"),dir);
@@ -747,6 +781,7 @@
char * subtitle = _("Loading graphics ...");
const char *config_file = "config.txt";
+ char * config_data_file;
FILE *fd = NULL ;
char line[128];
char *copy = NULL;
@@ -759,7 +794,11 @@
double newzoom = zoom;
int i;
- fd = fopen( data_file(config_file,1), "r" );
+ config_data_file = data_file(config_file,1);
+ if ( config_data_file == NULL ) {
+ fail(_("Couldn't find data file for splash screen"));
+ }
+ fd = fopen( config_data_file, "r" );
if(fd) { /* time to change default values... */
while ( fgets( line, 128, fd ) != NULL ) {
lc++;
--- End Message ---