diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-11-14 20:10:01 +0000 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-11-14 20:10:01 +0000 |
commit | 175f3b3e628e45197eb654c1bf99e12898184a2b (patch) | |
tree | 80f3f3d6544fdb7cd02e3586602672c6777670b6 /pkgs/development/libraries/libchop | |
parent | 63d36b5185544d168fdec43cce34a775f184f87a (diff) |
libchop: Add patches that fix the whole thing.
svn path=/nixpkgs/trunk/; revision=30430
Diffstat (limited to 'pkgs/development/libraries/libchop')
6 files changed, 200 insertions, 16 deletions
diff --git a/pkgs/development/libraries/libchop/0001-tests-Simplify-deserialize.c.patch b/pkgs/development/libraries/libchop/0001-tests-Simplify-deserialize.c.patch new file mode 100644 index 000000000000..137f127e8def --- /dev/null +++ b/pkgs/development/libraries/libchop/0001-tests-Simplify-deserialize.c.patch @@ -0,0 +1,103 @@ +From cb343e4e0421ba89651c884939238eec74e826f6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org> +Date: Mon, 14 Nov 2011 17:28:53 +0100 +Subject: [PATCH 1/2] tests: Simplify `deserialize.c'. + +* tests/interfaces/deserialize.c (pair)[serial_size]: Remove field. + (ascii_serials): Adjust accordingly. + (check_serial_deserial): Use `strlen (pair->serial)' instead of + `pair->serial_size'. +--- + tests/interfaces/deserialize.c | 20 +++++++++----------- + 1 files changed, 9 insertions(+), 11 deletions(-) + +diff --git a/tests/interfaces/deserialize.c b/tests/interfaces/deserialize.c +index 80c610d..6e9b765 100644 +--- a/tests/interfaces/deserialize.c ++++ b/tests/interfaces/deserialize.c +@@ -24,12 +24,12 @@ + + #include <testsuite.h> + #include <stdlib.h> ++#include <string.h> + + struct pair + { + const char *const class_name; + const char *const serial; +- size_t serial_size; + }; + + static const struct pair ascii_serials[] = +@@ -37,16 +37,14 @@ static const struct pair ascii_serials[] = + { + "chk_index_handle", + "zqoimseyv5r4cpj3ab64o6y2j6cbatkz5picnvidsyafwnvtrvbq====,grqqeqcihncuevm7xnmnkfp3ukkruk2e/4a", +- 92 + }, + + { + "hash_index_handle", + "3q2hrigwtmsmvqi64cy2yw7szh66drvf/122", +- 36 + }, + +- { NULL, NULL, 0 } ++ { NULL, NULL } + }; + + /* Check whether we can serialize/deserialize PAIR. */ +@@ -59,7 +57,7 @@ check_serial_deserial (const struct pair *pair) + chop_object_t *object; + const chop_class_t *klass; + chop_buffer_t buffer; +- char with_trailing_junk[pair->serial_size + sizeof junk + 1]; ++ char with_trailing_junk[strlen (pair->serial) + sizeof junk + 1]; + size_t read; + + test_stage ("instance of `%s'", pair->class_name); +@@ -73,17 +71,17 @@ check_serial_deserial (const struct pair *pair) + test_stage_intermediate ("with trailing NUL"); + err = chop_object_deserialize (object, klass, + CHOP_SERIAL_ASCII, +- pair->serial, pair->serial_size, ++ pair->serial, strlen (pair->serial), + &read); + + test_check_errcode (err, "deserializing"); +- test_assert (read == pair->serial_size); ++ test_assert (read == strlen (pair->serial)); + + err = chop_object_serialize (object, CHOP_SERIAL_ASCII, &buffer); + test_check_errcode (err, "serializing"); + + test_assert (!strncmp (chop_buffer_content (&buffer), pair->serial, +- pair->serial_size)); ++ strlen (pair->serial))); + + chop_object_destroy (object); + chop_buffer_clear (&buffer); +@@ -96,17 +94,17 @@ check_serial_deserial (const struct pair *pair) + + err = chop_object_deserialize (object, klass, + CHOP_SERIAL_ASCII, +- with_trailing_junk, pair->serial_size, ++ with_trailing_junk, strlen (pair->serial), + &read); + + test_check_errcode (err, "deserializing with trailing junk"); +- test_assert (read == pair->serial_size); ++ test_assert (read == strlen (pair->serial)); + + err = chop_object_serialize (object, CHOP_SERIAL_ASCII, &buffer); + test_check_errcode (err, "serializing (trailing junk)"); + + test_assert (!strncmp (chop_buffer_content (&buffer), pair->serial, +- pair->serial_size)); ++ strlen (pair->serial))); + + test_stage_result (1); + } +-- +1.7.6 + diff --git a/pkgs/development/libraries/libchop/0002-block-indexer-hash-Fix-off-by-n-in-ASCII-deserializa.patch b/pkgs/development/libraries/libchop/0002-block-indexer-hash-Fix-off-by-n-in-ASCII-deserializa.patch new file mode 100644 index 000000000000..4013f714880c --- /dev/null +++ b/pkgs/development/libraries/libchop/0002-block-indexer-hash-Fix-off-by-n-in-ASCII-deserializa.patch @@ -0,0 +1,47 @@ +From 8b2d0b3792e4c0535ff7241cf3770232618cdefc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org> +Date: Mon, 14 Nov 2011 17:34:10 +0100 +Subject: [PATCH 2/2] block-indexer-hash: Fix off-by-n in ASCII + deserialization of the block indexer. + +* src/block-indexer-hash.c (hbi_deserialize): Don't read beyond SIZE. + +* tests/interfaces/deserialize.c (ascii_serials): Add a + `hash_block_indexer' example. +--- + src/block-indexer-hash.c | 2 +- + tests/interfaces/deserialize.c | 5 +++++ + 2 files changed, 6 insertions(+), 1 deletions(-) + +diff --git a/src/block-indexer-hash.c b/src/block-indexer-hash.c +index 858ddd7..db7d6b4 100644 +--- a/src/block-indexer-hash.c ++++ b/src/block-indexer-hash.c +@@ -638,7 +638,7 @@ hbi_deserialize (const char *buffer, size_t size, chop_serial_method_t method, + size_t name_len = 0; + const char *end = buffer; + +- while (isalnum (*end)) ++ while (isalnum (*end) && end - buffer < size) + { + if (name_len >= sizeof (name)) + return CHOP_DESERIAL_CORRUPT_INPUT; +diff --git a/tests/interfaces/deserialize.c b/tests/interfaces/deserialize.c +index 6e9b765..af7015e 100644 +--- a/tests/interfaces/deserialize.c ++++ b/tests/interfaces/deserialize.c +@@ -44,6 +44,11 @@ static const struct pair ascii_serials[] = + "3q2hrigwtmsmvqi64cy2yw7szh66drvf/122", + }, + ++ { ++ "hash_block_indexer", ++ "SHA1" ++ }, ++ + { NULL, NULL } + }; + +-- +1.7.6 + diff --git a/pkgs/development/libraries/libchop/0003-fix-test-makefile.patch b/pkgs/development/libraries/libchop/0003-fix-test-makefile.patch new file mode 100644 index 000000000000..f8b4a0dff5c9 --- /dev/null +++ b/pkgs/development/libraries/libchop/0003-fix-test-makefile.patch @@ -0,0 +1,19 @@ +commit c1d42668b6fa0777df99c349a9b3826c186f3b9d +Author: Ludovic Courtès <ludo@gnu.org> +Date: Sat Nov 5 00:03:00 2011 +0100 + + Define $GUILE_LOAD_COMPILED_PATH when running tests. + + * tests/Makefile.am (TESTS_ENVIRONMENT): Define + $GUILE_LOAD_COMPILED_PATH. + +diff -ubB --show-c-function /tmp/nix-build-bzqif52j6ypbhrkyg13ikc1wzscg2h7s-libchop-0.5.drv-0/libchop-0.5/tests/Makefile.in.orig /tmp/nix-build-bzqif52j6ypbhrkyg13ikc1wzscg2h7s-libchop-0.5.drv-0/libchop-0.5/tests/Makefile.in +--- libchop-0.5/tests/Makefile.in 2011-11-14 17:42:14.000000000 +0100 ++++ libchop-0.5/tests/Makefile.in 2011-11-14 17:42:17.000000000 +0100 +@@ -1048,6 +1048,7 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPT + TESTS_ENVIRONMENT = \ + PATH="$(top_builddir)/utils:$$PATH" \ + GUILE_LOAD_PATH="$(abs_top_srcdir)/guile2:$(abs_top_builddir)/guile2:$$GUILE_LOAD_PATH" \ ++ GUILE_LOAD_COMPILED_PATH="$(abs_top_builddir)/guile2:$$GUILE_LOAD_COMPILED_PATH" \ + libchop_libdir="$(abs_top_builddir)/src" \ + top_srcdir="$(abs_top_srcdir)" srcdir="$(abs_srcdir)/utils" diff --git a/pkgs/development/libraries/libchop/0004-tests-Export-XDG_CACHE_HOME-in-utils-backup.patch b/pkgs/development/libraries/libchop/0004-tests-Export-XDG_CACHE_HOME-in-utils-backup.patch new file mode 100644 index 000000000000..1a6c1bf289ca --- /dev/null +++ b/pkgs/development/libraries/libchop/0004-tests-Export-XDG_CACHE_HOME-in-utils-backup.patch @@ -0,0 +1,25 @@ +From 55effc94ec10100673edc1400bc8cb086fd8dc3b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org> +Date: Mon, 14 Nov 2011 17:56:46 +0100 +Subject: [PATCH] tests: Export $XDG_CACHE_HOME in `utils/backup'. + +* tests/utils/backup (XDG_CACHE_HOME): Export. +--- + tests/utils/backup | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/tests/utils/backup b/tests/utils/backup +index d8db141..171060f 100755 +--- a/tests/utils/backup ++++ b/tests/utils/backup +@@ -21,6 +21,7 @@ source "${srcdir:-$PWD}/lib.sh" + DB_FILE=",,backup.db" + TMP_FILE=",,backup.tmp" + XDG_CACHE_HOME="$PWD/backup-cache" ++export XDG_CACHE_HOME + + chop_CLEANUP_HOOK='rm -rf "$XDG_CACHE_HOME" "$DB_FILE" "$TMP_FILE"' + +-- +1.7.6 + diff --git a/pkgs/development/libraries/libchop/default.nix b/pkgs/development/libraries/libchop/default.nix index f5b7f72f08f0..2d6f64a30579 100644 --- a/pkgs/development/libraries/libchop/default.nix +++ b/pkgs/development/libraries/libchop/default.nix @@ -9,7 +9,12 @@ stdenv.mkDerivation rec { sha256 = "0i7gl0c99pf6794bbwm3iha6a0bciqq969mgwwv6gm9phiiy5s8b"; }; - patches = [ ./guile-ascii-deserialize.patch ]; + patches = + [ ./0001-tests-Simplify-deserialize.c.patch + ./0002-block-indexer-hash-Fix-off-by-n-in-ASCII-deserializa.patch + ./0003-fix-test-makefile.patch + ./0004-tests-Export-XDG_CACHE_HOME-in-utils-backup.patch + ]; buildNativeInputs = [ pkgconfig gperf ]; buildInputs = diff --git a/pkgs/development/libraries/libchop/guile-ascii-deserialize.patch b/pkgs/development/libraries/libchop/guile-ascii-deserialize.patch deleted file mode 100644 index 6a2e67d870c8..000000000000 --- a/pkgs/development/libraries/libchop/guile-ascii-deserialize.patch +++ /dev/null @@ -1,15 +0,0 @@ -This fixes `deserialize-object/ascii'. - -diff --git a/guile2/chop/objects.scm b/guile2/chop/objects.scm -index 1849195..1aa521d 100644 ---- a/guile2/chop/objects.scm -+++ b/guile2/chop/objects.scm -@@ -133,7 +133,7 @@ - - (define (deserialize-object/ascii class str) - "Deserialize STR and return a new instance of CLASS that corresponds." -- (%deserialize-object class (string->utf8 str) %ascii)) -+ (%deserialize-object class (string->pointer str) %ascii)) - - (define (deserialize-object/binary class bv) - "Deserialize BV and return a new instance of CLASS that corresponds." |