"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/plugins/png_extractor.c" between
libextractor-1.5.tar.gz and libextractor-1.6.tar.gz

About: GNU libextractor is a library used to extract meta-data from files of arbitrary type.

png_extractor.c  (libextractor-1.5):png_extractor.c  (libextractor-1.6)
skipping to change at line 49 skipping to change at line 49
* @param str input string * @param str input string
* @param n length of the input * @param n length of the input
* @return n-bytes from str followed by 0-termination, NULL on error * @return n-bytes from str followed by 0-termination, NULL on error
*/ */
static char * static char *
stndup (const char *str, stndup (const char *str,
size_t n) size_t n)
{ {
char *tmp; char *tmp;
if (n + 1 < n)
return NULL;
if (NULL == (tmp = malloc (n + 1))) if (NULL == (tmp = malloc (n + 1)))
return NULL; return NULL;
tmp[n] = '\0'; tmp[n] = '\0';
memcpy (tmp, str, n); memcpy (tmp, str, n);
return tmp; return tmp;
} }
/** /**
* strnlen is GNU specific, let's redo it here to be * strnlen is GNU specific, let's redo it here to be
* POSIX compliant. * POSIX compliant.
skipping to change at line 216 skipping to change at line 218
if (length != ec->read (ec->cls, &ptr, length)) if (length != ec->read (ec->cls, &ptr, length))
return 1; return 1;
data = ptr; data = ptr;
pos = stnlen ((char *) data, length) + 1; pos = stnlen ((char *) data, length) + 1;
if (pos >= length) if (pos >= length)
return 0; return 0;
compressed = data[pos++]; compressed = data[pos++];
if (compressed && (0 != data[pos++])) if (compressed && (0 != data[pos++]))
return 0; /* bad compression method */ return 0; /* bad compression method */
if (pos > length)
return 0;
language = (char *) &data[pos]; language = (char *) &data[pos];
ret = 0; ret = 0;
if ( (stnlen (language, length - pos) > 0) && if ( (stnlen (language, length - pos) > 0) &&
(NULL != (lan = stndup (language, length - pos))) ) (NULL != (lan = stndup (language, length - pos))) )
ADDF (EXTRACTOR_METATYPE_LANGUAGE, lan); ADDF (EXTRACTOR_METATYPE_LANGUAGE, lan);
pos += stnlen (language, length - pos) + 1; pos += stnlen (language, length - pos) + 1;
if (pos + 1 >= length) if (pos + 1 >= length)
return 0; return 0;
translated = (char*) &data[pos]; /* already in utf-8! */ translated = (char*) &data[pos]; /* already in utf-8! */
if ( (stnlen (translated, length - pos) > 0) && if ( (stnlen (translated, length - pos) > 0) &&
 End of changes. 2 change blocks. 
0 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)