~ubuntu-branches/ubuntu/intrepid/libpng/intrepid-security

« back to all changes in this revision

Viewing changes to pngerror.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2006-11-21 19:07:43 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20061121190743-wkt0yzs5uq2xoq10
Tags: 1.2.13-4
Removed drop_pass_width patch. Closes: #399499.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngerror.c - stub functions for i/o and memory allocation
3
3
 *
4
 
 * libpng version 1.2.8 - December 3, 2004
 
4
 * Last changed in libpng 1.2.13 November 13, 2006
5
5
 * For conditions of distribution and use, see copyright notice in png.h
6
 
 * Copyright (c) 1998-2004 Glenn Randers-Pehrson
 
6
 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
7
7
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8
8
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9
9
 *
16
16
#define PNG_INTERNAL
17
17
#include "png.h"
18
18
 
 
19
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
19
20
static void /* PRIVATE */
20
21
png_default_error PNGARG((png_structp png_ptr,
21
22
  png_const_charp error_message));
33
34
{
34
35
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
35
36
   char msg[16];
36
 
   if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
 
37
   if (png_ptr != NULL)
37
38
   {
38
 
     if (*error_message == '#')
39
 
     {
40
 
         int offset;
41
 
         for (offset=1; offset<15; offset++)
42
 
            if (*(error_message+offset) == ' ')
43
 
                break;
44
 
         if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
45
 
         {
46
 
            int i;
47
 
            for (i=0; i<offset-1; i++)
48
 
               msg[i]=error_message[i+1];
49
 
            msg[i]='\0';
50
 
            error_message=msg;
51
 
         }
52
 
         else
53
 
            error_message+=offset;
54
 
     }
55
 
     else
56
 
     {
57
 
         if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
58
 
         {
59
 
            msg[0]='0';        
60
 
            msg[1]='\0';
61
 
            error_message=msg;
62
 
         }
 
39
     if (png_ptr->flags&
 
40
       (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
 
41
     {
 
42
       if (*error_message == '#')
 
43
       {
 
44
           int offset;
 
45
           for (offset=1; offset<15; offset++)
 
46
              if (*(error_message+offset) == ' ')
 
47
                  break;
 
48
           if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
 
49
           {
 
50
              int i;
 
51
              for (i=0; i<offset-1; i++)
 
52
                 msg[i]=error_message[i+1];
 
53
              msg[i]='\0';
 
54
              error_message=msg;
 
55
           }
 
56
           else
 
57
              error_message+=offset;
 
58
       }
 
59
       else
 
60
       {
 
61
           if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
 
62
           {
 
63
              msg[0]='0';
 
64
              msg[1]='\0';
 
65
              error_message=msg;
 
66
           }
 
67
       }
63
68
     }
64
69
   }
65
70
#endif
80
85
png_warning(png_structp png_ptr, png_const_charp warning_message)
81
86
{
82
87
   int offset = 0;
 
88
   if (png_ptr != NULL)
 
89
   {
83
90
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
84
 
   if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
 
91
   if (png_ptr->flags&
 
92
     (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
85
93
#endif
86
 
   {
87
 
     if (*warning_message == '#')
88
94
     {
89
 
         for (offset=1; offset<15; offset++)
90
 
            if (*(warning_message+offset) == ' ')
91
 
                break;
 
95
       if (*warning_message == '#')
 
96
       {
 
97
           for (offset=1; offset<15; offset++)
 
98
              if (*(warning_message+offset) == ' ')
 
99
                  break;
 
100
       }
92
101
     }
 
102
     if (png_ptr != NULL && png_ptr->warning_fn != NULL)
 
103
        (*(png_ptr->warning_fn))(png_ptr, warning_message+offset);
93
104
   }
94
 
   if (png_ptr != NULL && png_ptr->warning_fn != NULL)
95
 
      (*(png_ptr->warning_fn))(png_ptr, warning_message+offset);
96
105
   else
97
106
      png_default_warning(png_ptr, warning_message+offset);
98
107
}
146
155
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
147
156
{
148
157
   char msg[18+64];
149
 
   png_format_buffer(png_ptr, msg, error_message);
150
 
   png_error(png_ptr, msg);
 
158
   if (png_ptr == NULL)
 
159
     png_error(png_ptr, error_message);
 
160
   else
 
161
   {
 
162
     png_format_buffer(png_ptr, msg, error_message);
 
163
     png_error(png_ptr, msg);
 
164
   }
151
165
}
152
166
 
153
167
void PNGAPI
154
168
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
155
169
{
156
170
   char msg[18+64];
157
 
   png_format_buffer(png_ptr, msg, warning_message);
158
 
   png_warning(png_ptr, msg);
 
171
   if (png_ptr == NULL)
 
172
     png_warning(png_ptr, warning_message);
 
173
   else
 
174
   {
 
175
     png_format_buffer(png_ptr, msg, warning_message);
 
176
     png_warning(png_ptr, msg);
 
177
   }
159
178
}
160
179
 
161
180
/* This is the default error handling function.  Note that replacements for
193
212
#endif
194
213
 
195
214
#ifdef PNG_SETJMP_SUPPORTED
 
215
   if (png_ptr)
 
216
   {
196
217
#  ifdef USE_FAR_KEYWORD
197
218
   {
198
219
      jmp_buf jmpbuf;
201
222
   }
202
223
#  else
203
224
   longjmp(png_ptr->jmpbuf, 1);
204
 
# endif
 
225
#  endif
 
226
   }
205
227
#else
206
 
   /* make compiler happy */ ;
207
 
   if (png_ptr)
208
228
   PNG_ABORT();
209
229
#endif
210
230
#ifdef PNG_NO_CONSOLE_IO
265
285
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
266
286
   png_error_ptr error_fn, png_error_ptr warning_fn)
267
287
{
 
288
   if (png_ptr == NULL)
 
289
      return;
268
290
   png_ptr->error_ptr = error_ptr;
269
291
   png_ptr->error_fn = error_fn;
270
292
   png_ptr->warning_fn = warning_fn;
278
300
png_voidp PNGAPI
279
301
png_get_error_ptr(png_structp png_ptr)
280
302
{
 
303
   if (png_ptr == NULL)
 
304
      return NULL;
281
305
   return ((png_voidp)png_ptr->error_ptr);
282
306
}
283
307
 
293
317
   }
294
318
}
295
319
#endif
 
320
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */