diff mbox series

[applied] RHBZ1944096 - assertion failure during self comparison of systemd

Message ID 87o893f8ug.fsf@redhat.com
State New
Headers show
Series [applied] RHBZ1944096 - assertion failure during self comparison of systemd | expand

Commit Message

Dodji Seketeli Sept. 8, 2021, 2:19 p.m. UTC
Hello,

When reading the abixml representing an enumerator which value is
exactly either LLONG_MIN or LLONG_MAX, build_enum_type_decl fails
because we wrongly think that an underflow or overflow happened, while
using strtoll.

This patch fixes the condition used to detect {under,over}flow
whenusing strtoll.

	* src/abg-reader.cc (build_enum_type_decl): When strtoll detects
	an underflow or overflo, it sets errno to ERANGE.  So take that
	into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.

---
 src/abg-reader.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index f4fe4ce8..559f8210 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -4325,7 +4325,11 @@  build_enum_type_decl(read_context&	ctxt,
 	  if (a)
 	    {
 	      value = strtoll(CHAR_STR(a), NULL, 0);
-	      if (value == LLONG_MIN || value == LLONG_MAX)
+	      // when strtoll encounters overflow or underflow, errno
+	      // is set to ERANGE and the returned value is either
+	      // LLONG_MIN or LLONG_MAX.
+	      if ((errno == ERANGE)
+		  && (value == LLONG_MIN || value == LLONG_MAX))
 		return nil;
 	    }