aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTuan Hoang <tmhoang@linux.ibm.com>2019-04-09 13:38:26 +0200
committerAndy Postnikov <apostnikov@gmail.com>2019-04-12 22:03:04 +0300
commit3267ee639c46ab2fa84f4844799352b75cfb9d1d (patch)
tree4a15446778cf0ba15035dcc83adfd800252c8093
parentf5c37421126bd55d85d5b2354b73b480c97ba9a8 (diff)
downloadaports-3267ee639c46ab2fa84f4844799352b75cfb9d1d.tar.bz2
aports-3267ee639c46ab2fa84f4844799352b75cfb9d1d.tar.xz
testing/libyang: fix byte order on s390x
Copy upstream commits
-rw-r--r--testing/libyang/09e7159e4f91a39f3d19ba6590d558ab027a8a84.patch154
-rw-r--r--testing/libyang/5b3c324097fa3e122edb774213aeafd6eba137f9.patch136
-rw-r--r--testing/libyang/APKBUILD22
3 files changed, 304 insertions, 8 deletions
diff --git a/testing/libyang/09e7159e4f91a39f3d19ba6590d558ab027a8a84.patch b/testing/libyang/09e7159e4f91a39f3d19ba6590d558ab027a8a84.patch
new file mode 100644
index 0000000000..b6c54e5110
--- /dev/null
+++ b/testing/libyang/09e7159e4f91a39f3d19ba6590d558ab027a8a84.patch
@@ -0,0 +1,154 @@
+From 09e7159e4f91a39f3d19ba6590d558ab027a8a84 Mon Sep 17 00:00:00 2001
+From: Michal Vasko <mvasko@cesnet.cz>
+Date: Tue, 9 Apr 2019 12:19:54 +0200
+Subject: [PATCH] lyb BUGFIX big endian platforms fixes
+
+Refs #749
+---
+ src/parser_lyb.c | 41 +++++++++++++++++++----------------------
+ src/printer_lyb.c | 14 ++------------
+ 2 files changed, 21 insertions(+), 34 deletions(-)
+
+diff --git a/src/parser_lyb.c b/src/parser_lyb.c
+index 8baeabbf..3de1bb17 100644
+--- a/src/parser_lyb.c
++++ b/src/parser_lyb.c
+@@ -120,32 +120,29 @@ lyb_read(const char *data, uint8_t *buf, size_t count, struct lyb_state *lybs)
+ }
+
+ static int
+-lyb_read_number(uint64_t *num, size_t num_size, size_t bytes, const char *data, struct lyb_state *lybs)
++lyb_read_number(void *num, size_t num_size, size_t bytes, const char *data, struct lyb_state *lybs)
+ {
+ int r, ret = 0;
+- size_t i;
+- uint8_t byte;
+-
+- for (i = 0; i < bytes; ++i) {
+- ret += (r = lyb_read(data, &byte, 1, lybs));
+- LYB_HAVE_READ_RETURN(r, data, -1);
++ uint64_t buf = 0;
+
+- *(((uint8_t *)num) + i) = byte;
+- }
++ ret += (r = lyb_read(data, (uint8_t *)&buf, bytes, lybs));
++ LYB_HAVE_READ_RETURN(r, data, -1);
+
+ /* correct byte order */
++ buf = le64toh(buf);
++
+ switch (num_size) {
+ case 1:
+- /* no need to do anything */
++ *((uint8_t *)num) = buf;
+ break;
+ case 2:
+- *num = le16toh(*num);
++ *((uint16_t *)num) = buf;
+ break;
+ case 4:
+- *num = le32toh(*num);
++ *((uint32_t *)num) = buf;
+ break;
+ case 8:
+- *num = le64toh(*num);
++ *((uint64_t *)num) = buf;
+ break;
+ default:
+ LOGINT(lybs->ctx);
+@@ -182,7 +179,7 @@ lyb_read_string(const char *data, char **str, int with_length, struct lyb_state
+ size_t len = 0, cur_len;
+
+ if (with_length) {
+- ret += (r = lyb_read_number((uint64_t *)&len, sizeof len, 2, data, lybs));
++ ret += (r = lyb_read_number(&len, sizeof len, 2, data, lybs));
+ LYB_HAVE_READ_GOTO(r, data, error);
+ } else {
+ /* read until the end of this subtree */
+@@ -269,7 +266,7 @@ lyb_parse_model(const char *data, const struct lys_module **mod, struct lyb_stat
+ LYB_HAVE_READ_GOTO(r, data, error);
+
+ /* revision */
+- ret += (r = lyb_read(data, (uint8_t *)&rev, 2, lybs));
++ ret += (r = lyb_read_number(&rev, sizeof rev, 2, data, lybs));
+ LYB_HAVE_READ_GOTO(r, data, error);
+
+ if (rev) {
+@@ -470,20 +467,20 @@ lyb_parse_val_1(struct lys_type *type, LY_DATA_TYPE value_type, uint8_t value_fl
+ break;
+ case LY_TYPE_INT8:
+ case LY_TYPE_UINT8:
+- ret = lyb_read_number((uint64_t *)&value->uint8, sizeof value->uint8, 1, data, lybs);
++ ret = lyb_read_number(&value->uint8, sizeof value->uint8, 1, data, lybs);
+ break;
+ case LY_TYPE_INT16:
+ case LY_TYPE_UINT16:
+- ret = lyb_read_number((uint64_t *)&value->uint16, sizeof value->uint16, 2, data, lybs);
++ ret = lyb_read_number(&value->uint16, sizeof value->uint16, 2, data, lybs);
+ break;
+ case LY_TYPE_INT32:
+ case LY_TYPE_UINT32:
+- ret = lyb_read_number((uint64_t *)&value->uint32, sizeof value->uint32, 4, data, lybs);
++ ret = lyb_read_number(&value->uint32, sizeof value->uint32, 4, data, lybs);
+ break;
+ case LY_TYPE_DEC64:
+ case LY_TYPE_INT64:
+ case LY_TYPE_UINT64:
+- ret = lyb_read_number((uint64_t *)&value->uint64, sizeof value->uint64, 8, data, lybs);
++ ret = lyb_read_number(&value->uint64, sizeof value->uint64, 8, data, lybs);
+ break;
+ default:
+ return -1;
+@@ -1164,7 +1161,7 @@ lyb_parse_data_models(const char *data, struct lyb_state *lybs)
+ int i, r, ret = 0;
+
+ /* read model count */
+- ret += (r = lyb_read_number((uint64_t *)&lybs->mod_count, sizeof lybs->mod_count, 2, data, lybs));
++ ret += (r = lyb_read_number(&lybs->mod_count, sizeof lybs->mod_count, 2, data, lybs));
+ LYB_HAVE_READ_RETURN(r, data, -1);
+
+ lybs->models = malloc(lybs->mod_count * sizeof *lybs->models);
+@@ -1349,14 +1346,14 @@ lyd_lyb_data_length(const char *data)
+ LYB_HAVE_READ_GOTO(r, data, finish);
+
+ /* read model count */
+- ret += (r = lyb_read_number((uint64_t *)&lybs.mod_count, sizeof lybs.mod_count, 2, data, &lybs));
++ ret += (r = lyb_read_number(&lybs.mod_count, sizeof lybs.mod_count, 2, data, &lybs));
+ LYB_HAVE_READ_GOTO(r, data, finish);
+
+ /* read all models */
+ for (i = 0; i < lybs.mod_count; ++i) {
+ /* module name length */
+ len = 0;
+- ret += (r = lyb_read_number((uint64_t *)&len, sizeof len, 2, data, &lybs));
++ ret += (r = lyb_read_number(&len, sizeof len, 2, data, &lybs));
+ LYB_HAVE_READ_GOTO(r, data, finish);
+
+ /* model name */
+diff --git a/src/printer_lyb.c b/src/printer_lyb.c
+index 5a3deda5..928332af 100644
+--- a/src/printer_lyb.c
++++ b/src/printer_lyb.c
+@@ -480,20 +480,10 @@ lyb_write_start_subtree(struct lyout *out, struct lyb_state *lybs)
+ static int
+ lyb_write_number(uint64_t num, size_t bytes, struct lyout *out, struct lyb_state *lybs)
+ {
+- int ret = 0;
+- size_t i;
+- uint8_t byte;
+-
++ /* correct byte order */
+ num = htole64(num);
+- for (i = 0; i < bytes; ++i) {
+- byte = *(((uint8_t *)&num) + i);
+- ret += lyb_write(out, &byte, 1, lybs);
+- if (ret < 0) {
+- break;
+- }
+- }
+
+- return ret;
++ return lyb_write(out, (uint8_t *)&num, bytes, lybs);
+ }
+
+ static int
diff --git a/testing/libyang/5b3c324097fa3e122edb774213aeafd6eba137f9.patch b/testing/libyang/5b3c324097fa3e122edb774213aeafd6eba137f9.patch
new file mode 100644
index 0000000000..a589521c77
--- /dev/null
+++ b/testing/libyang/5b3c324097fa3e122edb774213aeafd6eba137f9.patch
@@ -0,0 +1,136 @@
+From 5b3c324097fa3e122edb774213aeafd6eba137f9 Mon Sep 17 00:00:00 2001
+From: Michal Vasko <mvasko@cesnet.cz>
+Date: Mon, 8 Apr 2019 13:45:21 +0200
+Subject: [PATCH] lyb parser BUGFIX correct byte order for all numbers
+
+Fixes #747
+---
+ src/parser_lyb.c | 50 ++++++++++++++++++++++++++++++------------------
+ 1 file changed, 31 insertions(+), 19 deletions(-)
+
+diff --git a/src/parser_lyb.c b/src/parser_lyb.c
+index 628fba91..8baeabbf 100644
+--- a/src/parser_lyb.c
++++ b/src/parser_lyb.c
+@@ -120,7 +120,7 @@ lyb_read(const char *data, uint8_t *buf, size_t count, struct lyb_state *lybs)
+ }
+
+ static int
+-lyb_read_number(uint64_t *num, size_t bytes, const char *data, struct lyb_state *lybs)
++lyb_read_number(uint64_t *num, size_t num_size, size_t bytes, const char *data, struct lyb_state *lybs)
+ {
+ int r, ret = 0;
+ size_t i;
+@@ -133,15 +133,32 @@ lyb_read_number(uint64_t *num, size_t bytes, const char *data, struct lyb_state
+ *(((uint8_t *)num) + i) = byte;
+ }
+
++ /* correct byte order */
++ switch (num_size) {
++ case 1:
++ /* no need to do anything */
++ break;
++ case 2:
++ *num = le16toh(*num);
++ break;
++ case 4:
++ *num = le32toh(*num);
++ break;
++ case 8:
++ *num = le64toh(*num);
++ break;
++ default:
++ LOGINT(lybs->ctx);
++ return -1;
++ }
++
+ return ret;
+ }
+
+ static int
+ lyb_read_enum(uint64_t *enum_idx, uint32_t count, const char *data, struct lyb_state *lybs)
+ {
+- int ret = 0;
+ size_t bytes;
+- uint64_t tmp_enum = 0;
+
+ if (count < (1 << 8)) {
+ bytes = 1;
+@@ -153,11 +170,9 @@ lyb_read_enum(uint64_t *enum_idx, uint32_t count, const char *data, struct lyb_s
+ bytes = 4;
+ }
+
+- /* The enum is always read into a uint64_t buffer */
+- ret = lyb_read_number(&tmp_enum, bytes, data, lybs);
+- *enum_idx = le64toh(tmp_enum);
+-
+- return ret;
++ /* enum is always read into a uint64_t buffer */
++ *enum_idx = 0;
++ return lyb_read_number(enum_idx, sizeof *enum_idx, bytes, data, lybs);
+ }
+
+ static int
+@@ -167,7 +182,7 @@ lyb_read_string(const char *data, char **str, int with_length, struct lyb_state
+ size_t len = 0, cur_len;
+
+ if (with_length) {
+- ret += (r = lyb_read_number((uint64_t *)&len, 2, data, lybs));
++ ret += (r = lyb_read_number((uint64_t *)&len, sizeof len, 2, data, lybs));
+ LYB_HAVE_READ_GOTO(r, data, error);
+ } else {
+ /* read until the end of this subtree */
+@@ -455,23 +470,20 @@ lyb_parse_val_1(struct lys_type *type, LY_DATA_TYPE value_type, uint8_t value_fl
+ break;
+ case LY_TYPE_INT8:
+ case LY_TYPE_UINT8:
+- ret = lyb_read_number((uint64_t *)&value->uint8, 1, data, lybs);
++ ret = lyb_read_number((uint64_t *)&value->uint8, sizeof value->uint8, 1, data, lybs);
+ break;
+ case LY_TYPE_INT16:
+ case LY_TYPE_UINT16:
+- ret = lyb_read_number((uint64_t *)&value->uint16, 2, data, lybs);
+- value->uint16 = le16toh(value->uint16);
++ ret = lyb_read_number((uint64_t *)&value->uint16, sizeof value->uint16, 2, data, lybs);
+ break;
+ case LY_TYPE_INT32:
+ case LY_TYPE_UINT32:
+- ret = lyb_read_number((uint64_t *)&value->uint32, 4, data, lybs);
+- value->uint32 = le32toh(value->uint32);
++ ret = lyb_read_number((uint64_t *)&value->uint32, sizeof value->uint32, 4, data, lybs);
+ break;
+ case LY_TYPE_DEC64:
+ case LY_TYPE_INT64:
+ case LY_TYPE_UINT64:
+- ret = lyb_read_number((uint64_t *)&value->uint64, 8, data, lybs);
+- value->uint64 = le64toh(value->uint64);
++ ret = lyb_read_number((uint64_t *)&value->uint64, sizeof value->uint64, 8, data, lybs);
+ break;
+ default:
+ return -1;
+@@ -1152,7 +1164,7 @@ lyb_parse_data_models(const char *data, struct lyb_state *lybs)
+ int i, r, ret = 0;
+
+ /* read model count */
+- ret += (r = lyb_read_number((uint64_t *)&lybs->mod_count, 2, data, lybs));
++ ret += (r = lyb_read_number((uint64_t *)&lybs->mod_count, sizeof lybs->mod_count, 2, data, lybs));
+ LYB_HAVE_READ_RETURN(r, data, -1);
+
+ lybs->models = malloc(lybs->mod_count * sizeof *lybs->models);
+@@ -1337,14 +1349,14 @@ lyd_lyb_data_length(const char *data)
+ LYB_HAVE_READ_GOTO(r, data, finish);
+
+ /* read model count */
+- ret += (r = lyb_read_number((uint64_t *)&lybs.mod_count, 2, data, &lybs));
++ ret += (r = lyb_read_number((uint64_t *)&lybs.mod_count, sizeof lybs.mod_count, 2, data, &lybs));
+ LYB_HAVE_READ_GOTO(r, data, finish);
+
+ /* read all models */
+ for (i = 0; i < lybs.mod_count; ++i) {
+ /* module name length */
+ len = 0;
+- ret += (r = lyb_read_number((uint64_t *)&len, 2, data, &lybs));
++ ret += (r = lyb_read_number((uint64_t *)&len, sizeof len, 2, data, &lybs));
+ LYB_HAVE_READ_GOTO(r, data, finish);
+
+ /* model name */
diff --git a/testing/libyang/APKBUILD b/testing/libyang/APKBUILD
index bf3d626875..097daebd22 100644
--- a/testing/libyang/APKBUILD
+++ b/testing/libyang/APKBUILD
@@ -3,21 +3,27 @@
pkgname=libyang
pkgver=1.0_p2
_realver=${pkgver/_p/-r}
-pkgrel=0
+pkgrel=1
pkgdesc="YANG data modelling language parser and toolkit"
url="https://github.com/CESNET/libyang"
-arch="all !s390x"
+arch="all"
license="BSD-3-Clause-Clear"
depends=""
makedepends="bison cmake cmocka-dev flex pcre-dev"
install=""
subpackages="$pkgname-dev $pkgname-doc"
-source="${pkgname}-${pkgver}.tar.gz::https://github.com/CESNET/$pkgname/archive/v$_realver.tar.gz"
+source="${pkgname}-${pkgver}.tar.gz::https://github.com/CESNET/$pkgname/archive/v$_realver.tar.gz
+ 5b3c324097fa3e122edb774213aeafd6eba137f9.patch
+ 09e7159e4f91a39f3d19ba6590d558ab027a8a84.patch
+ "
builddir="$srcdir/$pkgname-$_realver/build"
-build() {
+prepare() {
mkdir -p "$builddir"
- cd "$builddir"
+ builddir="$builddir/.." default_prepare
+}
+
+build() {
if [ "$CBUILD" != "$CHOST" ]; then
CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
fi
@@ -35,13 +41,13 @@ build() {
}
check() {
- cd "$builddir"
make test
}
package() {
- cd "$builddir"
make DESTDIR="$pkgdir" install
}
-sha512sums="1ed184b43b2163fe15bb13e683083a142f8624430b00a6f491d58a52ce4bde5603c1a0b5aac6cd314de1b5c9c608bee0ad7a1409c7be14836debe4c348b7a915 libyang-1.0_p2.tar.gz"
+sha512sums="1ed184b43b2163fe15bb13e683083a142f8624430b00a6f491d58a52ce4bde5603c1a0b5aac6cd314de1b5c9c608bee0ad7a1409c7be14836debe4c348b7a915 libyang-1.0_p2.tar.gz
+6878f0ba6994242ea89b48d2a4cc24a64c368cc597de5ef7f8d8d30c531eb18ac39b5c6ecb3c19e73f30b9f62a854c9c7be03d748f338386781d343f432faf88 5b3c324097fa3e122edb774213aeafd6eba137f9.patch
+90af183226d757085d728db8ef6e2c5070885519e6eba17a38b4cb6343518030e52d154b0ff45fa9d95373e173b97bb3d9edb701ccede7e2ef0573b75083880c 09e7159e4f91a39f3d19ba6590d558ab027a8a84.patch"