update rest to 0.9.1

This commit is contained in:
sherlock2010 2023-02-02 12:26:06 +00:00
parent 83c0ecc441
commit 95608bd25d
7 changed files with 132 additions and 282 deletions

View File

@ -0,0 +1,40 @@
From fbad64abe28a96f591a30e3a5d3189c10172a414 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 30 Aug 2022 10:03:57 -0700
Subject: [PATCH 1/2] rest_proxy_call_sync: bail out if no payload
goa-daemon is crashing on suspend/resume with a traceback that
points here: it calls rest_proxy_call_sync, that calls
_rest_proxy_send_message, assumes it gets a `payload` back,
and calls `finish_call` with it. However, it's not actually
guaranteed that `_rest_proxy_send_message` will return a payload
(a `GBytes`). There are three ways it can return `NULL` instead:
if it's passed a wrong proxy or message, or - when built against
libsoup3 - if there is an error sending the message (it passes
through the return value of `soup_session_send_and_read`, and
that's documented to be `NULL` on error).
If `payload` comes back `NULL`, let's just return `FALSE`, like
we do if there's a problem with the call or message.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
rest/rest-proxy-call.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 851b397..07b8b49 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -1428,6 +1428,8 @@ rest_proxy_call_sync (RestProxyCall *call,
return FALSE;
payload = _rest_proxy_send_message (priv->proxy, message, priv->cancellable, error_out);
+ if (!payload)
+ return FALSE;
ret = finish_call (call, message, payload, error_out);
--
2.37.1

View File

@ -0,0 +1,52 @@
From 49c2d0ac00b959ce53cc00ca4e7758c21085722f Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 30 Aug 2022 10:59:01 -0700
Subject: [PATCH 2/2] Handle some potential problems in parsing oauth2 access
tokens
It's possible for `_rest_proxy_send_message` to return `NULL`,
which would mean the `payload` here would be `NULL`. If so,
we're not going to be able to do anything, so we should just
bail out.
It's also possible for `json_parser_load_from_data` to return
`FALSE` without setting an error. The most obvious way would be
if `data` was `NULL`, which the bailout avoids, but it could
also happen if we pass an invalid parser somehow. Let's just
handle that too, to be safe.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
rest/rest-oauth2-proxy.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/rest/rest-oauth2-proxy.c b/rest/rest-oauth2-proxy.c
index 9511f97..a715b2b 100644
--- a/rest/rest-oauth2-proxy.c
+++ b/rest/rest-oauth2-proxy.c
@@ -68,18 +68,21 @@ rest_oauth2_proxy_parse_access_token (RestOAuth2Proxy *self,
gsize size;
gint expires_in;
gint created_at;
+ gboolean ret;
g_return_if_fail (REST_IS_OAUTH2_PROXY (self));
+ g_return_if_fail (payload);
data = g_bytes_get_data (payload, &size);
parser = json_parser_new ();
- json_parser_load_from_data (parser, data, size, &error);
+ ret = json_parser_load_from_data (parser, data, size, &error);
if (error != NULL)
{
g_task_return_error (task, error);
return;
}
+ g_return_if_fail (ret);
root = json_parser_get_root (parser);
root_object = json_node_get_object (root);
--
2.37.1

View File

@ -1,50 +0,0 @@
From a217a9fea1a1cfb2bee3263b0ea08b860535af8d Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Mon, 16 Oct 2017 10:48:33 +0200
Subject: [PATCH] xml: Don't crash parsing empty XML string
Calling rest_xml_parser_parse_from_data() with an empty string ("")
currently causes a crash as xmlReaderForMemory() returns NULL in that
case, and we then try to dereference this pointer without checking it's
non-NULL.
https://bugzilla.gnome.org/show_bug.cgi?id=789053
---
rest/rest-xml-parser.c | 3 +++
tests/xml.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c
index ffa6ff3..796052e 100644
--- a/rest/rest-xml-parser.c
+++ b/rest/rest-xml-parser.c
@@ -103,6 +103,9 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
NULL, /* URL? */
NULL, /* encoding */
XML_PARSE_RECOVER | XML_PARSE_NOCDATA);
+ if (reader == NULL) {
+ return NULL;
+ }
xmlTextReaderSetErrorHandler(reader, rest_xml_parser_xml_reader_error, NULL);
while (xmlTextReaderRead (reader) == 1)
diff --git a/tests/xml.c b/tests/xml.c
index 4b7718b..9d03e29 100644
--- a/tests/xml.c
+++ b/tests/xml.c
@@ -34,6 +34,12 @@ main (int argc, char **argv)
parser = rest_xml_parser_new ();
+ root = rest_xml_parser_parse_from_data (parser, "", -1);
+ g_assert (root == NULL);
+
+ root = rest_xml_parser_parse_from_data (parser, "<invalid", -1);
+ g_assert (root == NULL);
+
root = rest_xml_parser_parse_from_data (parser, TEST_XML, strlen (TEST_XML));
g_assert (root);
--
2.33.0

View File

@ -1,218 +0,0 @@
From a09ea6bd74d6234be8456e7039403bc1c1d078bd Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Mon, 20 Jun 2016 12:05:48 +0200
Subject: [PATCH 1/4] xml-node: Use GString in rest_xml_node_print()
The current code is using xml = g_strconcat (xml, ...) which is causing
some leaks as g_strconcat returns a newly allocated string. Using
GString avoids this issue without constantly freeing the intermediate
strings.
This fixes multiple leaks like:
==16611== 18 bytes in 1 blocks are definitely lost in loss record 124 of 301
==16611== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==16611== by 0x5F5CE58: g_malloc (gmem.c:94)
==16611== by 0x5F75B8E: g_strconcat (gstrfuncs.c:585)
==16611== by 0x4E450CF: rest_xml_node_print (rest-xml-node.c:287)
==16611== by 0x4E451DA: rest_xml_node_print (rest-xml-node.c:305)
==16611== by 0x4E450F8: rest_xml_node_print (rest-xml-node.c:292)
==16611== by 0x4009A0: main (xml.c:40)
---
rest/rest-xml-node.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/rest/rest-xml-node.c b/rest/rest-xml-node.c
index 57a942667f06..a8156dbbd432 100644
--- a/rest/rest-xml-node.c
+++ b/rest/rest-xml-node.c
@@ -283,38 +283,41 @@ rest_xml_node_print (RestXmlNode *node)
{
GHashTableIter iter;
gpointer key, value;
- char *xml = g_strconcat ("<", node->name, NULL);
+ GString *xml = g_string_new (NULL);
RestXmlNode *n;
+ g_string_append (xml, "<");
+ g_string_append (xml, node->name);
+
g_hash_table_iter_init (&iter, node->attrs);
while (g_hash_table_iter_next (&iter, &key, &value))
- xml = g_strconcat (xml, " ", key, "=\'", value, "\'", NULL);
+ g_string_append_printf (xml, " %s =\'%s\'", (char *)key, (char *)value);
- xml = g_strconcat (xml, ">", NULL);
+ g_string_append (xml, ">");
g_hash_table_iter_init (&iter, node->children);
while (g_hash_table_iter_next (&iter, &key, &value))
{
char *child = rest_xml_node_print ((RestXmlNode *) value);
- xml = g_strconcat (xml, child, NULL);
+ g_string_append (xml, child);
g_free (child);
}
if (node->content)
- xml = g_strconcat (xml, node->content, "</", node->name, ">", NULL);
- else
- xml = g_strconcat (xml, "</", node->name, ">", NULL);
+ g_string_append (xml, node->content);
+
+ g_string_append_printf (xml, "</%s>", node->name);
for (n = node->next; n; n = n->next)
{
char *sibling = rest_xml_node_print (n);
- xml = g_strconcat (xml, sibling, NULL);
+ g_string_append (xml, sibling);
g_free (sibling);
}
- return xml;
+ return g_string_free (xml, FALSE);
}
/**
--
2.14.2
From a34d02947c4f102e6d16b9d328941a4b2946c8e8 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 13 Oct 2017 18:53:39 +0200
Subject: [PATCH 2/4] xml-node: Remove stray blank space
This had broken tests/xml.c.
Fallout from 61a7b231bd8b9d1b8d02dca120389e79d38b428d
https://bugzilla.gnome.org/show_bug.cgi?id=788960
---
rest/rest-xml-node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rest/rest-xml-node.c b/rest/rest-xml-node.c
index a8156dbbd432..d3a7c995affd 100644
--- a/rest/rest-xml-node.c
+++ b/rest/rest-xml-node.c
@@ -291,7 +291,7 @@ rest_xml_node_print (RestXmlNode *node)
g_hash_table_iter_init (&iter, node->attrs);
while (g_hash_table_iter_next (&iter, &key, &value))
- g_string_append_printf (xml, " %s =\'%s\'", (char *)key, (char *)value);
+ g_string_append_printf (xml, " %s=\'%s\'", (char *)key, (char *)value);
g_string_append (xml, ">");
--
2.14.2
From f184db2bff0618b99c4de3316082fe80439f124c Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 13 Oct 2017 19:14:16 +0200
Subject: [PATCH 3/4] xml-node: Define the order in which attributes & children
are printed
The order in which GHashTable returns its key-value pairs is undefined.
Therefore the output of rest_xml_node_print can change based on the
GHashTable implementation. While not strictly necessary, it would be
nice to avoid that. Having a stable order, even if it is not
documented and depends on the current RestXmlNode code, is handy for
testing.
This was the main reason behind the tests/xml.c breakage.
https://bugzilla.gnome.org/show_bug.cgi?id=788960
---
rest/rest-xml-node.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/rest/rest-xml-node.c b/rest/rest-xml-node.c
index d3a7c995affd..973ebcf6c3fa 100644
--- a/rest/rest-xml-node.c
+++ b/rest/rest-xml-node.c
@@ -283,6 +283,9 @@ rest_xml_node_print (RestXmlNode *node)
{
GHashTableIter iter;
gpointer key, value;
+ GList *attrs = NULL;
+ GList *children = NULL;
+ GList *l;
GString *xml = g_string_new (NULL);
RestXmlNode *n;
@@ -291,13 +294,29 @@ rest_xml_node_print (RestXmlNode *node)
g_hash_table_iter_init (&iter, node->attrs);
while (g_hash_table_iter_next (&iter, &key, &value))
- g_string_append_printf (xml, " %s=\'%s\'", (char *)key, (char *)value);
+ {
+ char *attr = g_strdup_printf ("%s=\'%s\'", (char *)key, (char *)value);
+ attrs = g_list_prepend (attrs, attr);
+ }
+
+ attrs = g_list_sort (attrs, (GCompareFunc) g_strcmp0);
+ for (l = attrs; l; l = l->next)
+ {
+ const char *attr = (const char *) l->data;
+ g_string_append_printf (xml, " %s", attr);
+ }
g_string_append (xml, ">");
g_hash_table_iter_init (&iter, node->children);
while (g_hash_table_iter_next (&iter, &key, &value))
+ children = g_list_prepend (children, key);
+
+ children = g_list_sort (children, (GCompareFunc) g_strcmp0);
+ for (l = children; l; l = l->next)
{
+ const char *name = (const char *) l->data;
+ RestXmlNode *value = (RestXmlNode *) g_hash_table_lookup (node->children, name);
char *child = rest_xml_node_print ((RestXmlNode *) value);
g_string_append (xml, child);
@@ -317,6 +336,8 @@ rest_xml_node_print (RestXmlNode *node)
g_free (sibling);
}
+ g_list_free_full (attrs, g_free);
+ g_list_free (children);
return g_string_free (xml, FALSE);
}
--
2.14.2
From e5ee6ef751ee5a38d7b9fadcd631cf6ecec7b240 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 13 Oct 2017 19:16:55 +0200
Subject: [PATCH 4/4] tests: Re-enable the XML test
This reverts commit 2d1dbfe7073b1e153ff881426b40a9a517fb796b
https://bugzilla.gnome.org/show_bug.cgi?id=788960
---
tests/Makefile.am | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5d77f9cf5445..5ffdd4634e9a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,4 @@
TESTS = proxy proxy-continuous threaded oauth oauth-async oauth2 flickr lastfm xml custom-serialize
-# TODO: fix this test case
-XFAIL_TESTS = xml
AM_CPPFLAGS = $(SOUP_CFLAGS) -I$(top_srcdir) $(GCOV_CFLAGS)
AM_LDFLAGS = $(SOUP_LIBS) $(GCOV_LDFLAGS) \
--
2.14.2

Binary file not shown.

BIN
rest-0.9.1.tar.xz Normal file

Binary file not shown.

View File

@ -1,16 +1,17 @@
Name: rest
Version: 0.8.1
Release: 8
Version: 0.9.1
Release: 1
Summary: A library for access to RESTful web services
License: LGPLv2
URL: https://www.gnome.org
Source0: https://download.gnome.org/sources/%{name}/0.8/%{name}-%{version}.tar.xz
Source0: https://download.gnome.org/sources/%{name}/0.9/%{name}-%{version}.tar.xz
Patch0: rest-0.8.0-fix-the-XML-test.patch
Patch1: backport-xml-Don-t-crash-parsing-empty-XML-string.patch
Patch0: 0001-rest_proxy_call_sync-bail-out-if-no-payload.patch
Patch1: 0002-Handle-some-potential-problems-in-parsing-oauth2-acc.patch
BuildRequires: glib2-devel libsoup-devel libxml2-devel gobject-introspection-devel
BuildRequires: gtk-doc autoconf automake libtool libxslt
BuildRequires: glib2-devel libsoup3-devel libxml2-devel gobject-introspection-devel
BuildRequires: libxslt meson json-glib-devel libadwaita-devel gtksourceview5-devel gi-docgen
BuildRequires: rest rest-devel
%description
This library has been designed to make it easier to access web services that
@ -25,20 +26,30 @@ Requires: %{name} = %{version}-%{release}
%description devel
This package is the development files for rest.
%package demo
Summary: Demo application for %{name}
Requires: %{name} = %{version}-%{release}
%description demo
Demo application for %{name}.
%package_help
%prep
%autosetup -n %{name}-%{version} -p1
%build
autoreconf -fiv
%configure --enable-gtk-doc --enable-introspection=yes
%make_build
%meson
%meson_build
%install
%make_install
%delete_la
%meson_install
cp -a %{_libdir}/librest*-0.7.so* %{buildroot}%{_libdir}
cp -a %{_libdir}/girepository-1.0/Rest*-0.7.typelib %{buildroot}%{_libdir}/girepository-1.0/
cp -a %{_libdir}/pkgconfig/rest*-0.7.pc %{buildroot}%{_libdir}/pkgconfig
cp -a %{_includedir}/rest-0.7 %{buildroot}%{_includedir}
cp -a %{_datadir}/gir-1.0/Rest*-0.7.gir %{buildroot}%{_datadir}/gir-1.0/
%ldconfig_scriptlets
@ -48,6 +59,8 @@ autoreconf -fiv
%license COPYING
%{_libdir}/librest-0.7.so.*
%{_libdir}/librest-extras-0.7.so.*
%{_libdir}/librest-1.0.so.*
%{_libdir}/librest-extras-1.0.so.*
%{_libdir}/girepository-1.0/Rest-*
%{_libdir}/girepository-1.0/RestExtras-*
@ -57,16 +70,29 @@ autoreconf -fiv
%{_includedir}/rest-0.7
%{_libdir}/librest-0.7.so
%{_libdir}/librest-extras-0.7.so
%{_includedir}/rest-1.0
%{_libdir}/librest-1.0.so
%{_libdir}/librest-extras-1.0.so
%{_datadir}/gir-1.0/Rest-*
%{_datadir}/gir-1.0/RestExtras-*
%{_libdir}/pkgconfig/rest*
%files demo
%{_datadir}/applications/org.gnome.RestDemo.desktop
%{_bindir}/librest-demo
%files help
%defattr(-,root,root)
%doc README
%{_datadir}/gtk-doc/html/rest-0.7
%doc README.md
%{_datadir}/doc/librest-1.0
%changelog
* Thu Feb 02 2023 zhouyihang <zhouyihang3@h-partners.com> - 0.9.1-1
- Type:requirements
- Id:NA
- SUG:NA
- DESC:update rest to 0.9.1
* Wed Nov 09 2022 zhouyihang <zhouyihang3@h-partners.com> - 0.8.1-8
- Type:bugfix
- Id:NA