[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pickles: fix LEB128 and ULEB128 value calculation
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pickles: fix LEB128 and ULEB128 value calculation |
Date: |
Tue, 08 Mar 2022 11:33:56 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2022-03-08 Jose E. Marchesi <jemarch@gnu.org>
* pickles/leb128.pk (LEB128.value): Really allow up to 64-bit
integers and fix calculation of the return value.
(ULEB128.value): Likewise.
Reported and fixed by bjorn3 in the IRC channel.
---
ChangeLog | 7 +++++++
pickles/leb128.pk | 8 ++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 78c6b8a5..8d56ee11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-03-08 Jose E. Marchesi <jemarch@gnu.org>
+
+ * pickles/leb128.pk (LEB128.value): Really allow up to 64-bit
+ integers and fix calculation of the return value.
+ (ULEB128.value): Likewise.
+ Reported and fixed by bjorn3 in the IRC channel.
+
2022-02-07 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poked/usock.c (usock_client_step): Handle zero-length payloads.
diff --git a/pickles/leb128.pk b/pickles/leb128.pk
index f35628ab..7050639e 100644
--- a/pickles/leb128.pk
+++ b/pickles/leb128.pk
@@ -39,7 +39,7 @@ type ULEB128 =
fun extract = (uint<64> b) uint<64>: { return (b & 0x7f) <<. shift; }
/* poke supports up to 64-bit integers. */
- if (variable'length > 8)
+ if (variable'length > 9)
raise E_generic;
for (v in variable)
@@ -47,7 +47,7 @@ type ULEB128 =
result = result | extract (v);
shift = shift + 7;
}
- result = extract (last);
+ result |= extract (last);
return result;
}
@@ -85,7 +85,7 @@ type LEB128 =
fun extract = (int<64> b) int<64>: { return (b & 0x7f) <<. shift; }
/* poke supports up to 64-bit integers. */
- if (variable'length > 8)
+ if (variable'length > 9)
raise E_generic;
for (v in variable)
@@ -93,7 +93,7 @@ type LEB128 =
result = result | extract (v);
shift = shift + 7;
}
- result = extract (last);
+ result |= extract (last);
if (shift < (variable'size/#B) && last & 0b1000_0000)
result = result | (!0 <<. shift);
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pickles: fix LEB128 and ULEB128 value calculation,
Jose E. Marchesi <=