This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 59b7db7636f17da18520d71c091dd9c23694ea91 (commit) via c5adff16bfbf788991b9417d59a72d3d91645348 (commit) from 4e5922461f14819e66ba93de4097db1fd5343c4c (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/59b7db7636f17da18520d71c091dd9c23694e...
commit 59b7db7636f17da18520d71c091dd9c23694ea91 Author: Cyril Hrubis metan@ucw.cz Date: Tue Apr 9 13:59:05 2013 +0200
loaders: LoadImage: Fixes.
* Set errno to ENOSYS when signature loader was not found
* close file if image signature wasn't read (fixes memleak)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c index 07ef69c..4e154e9 100644 --- a/libs/loaders/GP_Loader.c +++ b/libs/loaders/GP_Loader.c @@ -217,26 +217,37 @@ static const GP_Loader *loader_by_signature(const char *path) FILE *f; int err;
- GP_DEBUG(1, "Trying to load a file by signature"); + const GP_Loader *ret; + + GP_DEBUG(1, "Trying to load by file signature");
f = fopen(path, "rb");
if (f == NULL) { err = errno; GP_DEBUG(1, "Failed to open file '%s'", path); - errno = err; - return NULL; + goto err0; }
if (fread(buf, sizeof(buf), 1, f) < 1) { GP_DEBUG(1, "Failed to read start of the file '%s'", path); - errno = EIO; - return NULL; + err = EIO; + goto err1; }
fclose(f);
- return GP_MatchSignature(buf); + ret = GP_MatchSignature(buf); + + if (ret == NULL) + errno = ENOSYS; + + return ret; +err1: + fclose(f); +err0: + errno = err; + return NULL; }
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
http://repo.or.cz/w/gfxprim.git/commit/c5adff16bfbf788991b9417d59a72d3d91645...
commit c5adff16bfbf788991b9417d59a72d3d91645348 Author: Cyril Hrubis metan@ucw.cz Date: Tue Apr 9 13:04:01 2013 +0200
tests: loaders_suite: Fixes.
* Update the negative loader testcases
- Write 32 zero bytes to the dummy file so that signature could be read by the loader
- Add check malloc flag
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 3802caa..1de4fef 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -399,30 +399,70 @@ struct file_testcase { int expected_errno; };
+enum file_flags { + FILE_CREATE = 0x01, + FILE_FILL = 0x02, +}; + static struct file_testcase file_testcases[] = { - {"a", 1, ENOSYS}, - {".a", 1, ENOSYS}, - {"a.", 1, ENOSYS}, - {".bc", 1, ENOSYS}, - {"bc", 1, ENOSYS}, - {"abc", 1, ENOSYS}, - {"png.", 1, ENOSYS}, - {"jpg.", 1, ENOSYS}, - {"gif.", 1, ENOSYS}, - {"jpeg.", 1, ENOSYS}, - {"bmp.", 1, ENOSYS}, - {".jpg", 1, EIO}, - {"img.jpg", 1, EIO}, - {".png", 1, EIO}, - {"img.png", 1, EIO}, - {".gif", 1, EIO}, - {"img.gif", 1, EIO}, - {".bmp", 1, EIO}, - {"img.bmp", 1, EIO}, - {".pbm", 1, EIO}, - {".pgm", 1, EIO}, - {".ppm", 1, EIO}, + /* + * Should fail the file signature based loader + * as the signature could have been loaded but + * the file format is unknown. + */ + {"a", FILE_CREATE | FILE_FILL, ENOSYS}, + {".a", FILE_CREATE | FILE_FILL, ENOSYS}, + {"a.", FILE_CREATE | FILE_FILL, ENOSYS}, + {".bc", FILE_CREATE | FILE_FILL, ENOSYS}, + {"bc", FILE_CREATE | FILE_FILL, ENOSYS}, + {"abc", FILE_CREATE | FILE_FILL, ENOSYS}, + + /* + * Should fail the corresponding loader and + * then fail the signature based loader too. + */ + {"wrong.png", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.jpg", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.gif", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.jpeg", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.bmp", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.psp", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.tif", FILE_CREATE | FILE_FILL, ENOSYS}, + {"wrong.tiff", FILE_CREATE | FILE_FILL, ENOSYS}, + + /* + * Should start signature-based loader and + * fail it to read start of the file. + */ + {"b", FILE_CREATE, EIO}, + {".b", FILE_CREATE, EIO}, + {"b.", FILE_CREATE, EIO}, + {".dc", FILE_CREATE, EIO}, + {"dc", FILE_CREATE, EIO}, + {"cba", FILE_CREATE, EIO}, + + /* + * Dtto but for hits the extension based + * loader first and fail to read image header + * in the particular loader. + */ + {"empty.jpg", FILE_CREATE, EIO}, + {"empty.png", FILE_CREATE, EIO}, + {"empty.gif", FILE_CREATE, EIO}, + {"empty.jpeg", FILE_CREATE, EIO}, + {"empty.bmp", FILE_CREATE, EIO}, + {"empty.psp", FILE_CREATE, EIO}, + {"empty.tif", FILE_CREATE, EIO}, + {"empty.tiff", FILE_CREATE, EIO}, + + {".jpg", FILE_CREATE, EIO}, + {".png", FILE_CREATE, EIO}, + {".gif", FILE_CREATE, EIO}, + {".jpeg", FILE_CREATE, EIO}, + {".bmp", FILE_CREATE, EIO}, + {".psp", FILE_CREATE, EIO}, + {".tiff", FILE_CREATE, EIO},
{"not_here.jpg", 0, ENOENT},
@@ -437,14 +477,27 @@ static int test_Load(void)
/* Create empty files */ for (i = 0; file_testcases[i].filename != NULL; i++) { - - if (file_testcases[i].create != 1) + + if (!(file_testcases[i].create & FILE_CREATE)) continue;
- FILE *f = fopen(file_testcases[i].filename, "w"); + FILE *f = fopen(file_testcases[i].filename, "wb"); + + if (f != NULL) { + char buf[128] = {0}; + + if (file_testcases[i].create & FILE_FILL) { + if (fwrite(buf, sizeof(buf), 1, f) != 1) + tst_msg("Failed to write to '%s'", + file_testcases[i].filename); + + }
- if (f != NULL) fclose(f); + } else { + tst_msg("Failed to open file '%s' for writing", + file_testcases[i].filename); + } }
for (i = 0; file_testcases[i].filename != NULL; i++) { @@ -469,7 +522,7 @@ static int test_Load(void) continue; } - if (file_testcases[i].expected_errno != errno) { + if (file_testcases[i].expected_errno != saved_errno) { tst_msg("Expected errno %i (%s) got %i (%s) on '%s'", file_testcases[i].expected_errno, strerror(file_testcases[i].expected_errno), @@ -623,7 +676,7 @@ const struct tst_suite tst_suite = { /* Generic GP_LoadImage test */ {.name = "Image Load", .tst_fn = test_Load, - .flags = TST_TMPDIR}, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, /* Callback abort tests */ {.name = "PNG Load abort", .tst_fn = test_PNG_Load_abort,
-----------------------------------------------------------------------
Summary of changes: libs/loaders/GP_Loader.c | 23 ++++++-- tests/loaders/loaders_suite.c | 109 ++++++++++++++++++++++++++++++----------- 2 files changed, 98 insertions(+), 34 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.