Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 1477
Content-Disposition: inline; filename="vte-CVE-2012-2738-pt1.patch"
Last-Modified: Thu, 23 Jan 2025 14:40:32 GMT
Expires: Sun, 21 Jan 2035 14:40:32 GMT
ETag: "fd454079390f3e6c5f7d28b0d8d6084cf3b726ec"

From feeee4b5832b17641e505b7083e0d299fdae318e Mon Sep 17 00:00:00 2001
From: Christian Persch <chpe@gnome.org>
Date: Sat, 19 May 2012 17:36:09 +0000
Subject: emulation: Limit integer arguments to 65535

To guard against malicious sequences containing excessively big numbers,
limit all parsed numbers to 16 bit range. Doing this here in the parsing
routine is a catch-all guard; this doesn't preclude enforcing
more stringent limits in the handlers themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=676090
---
diff --git a/src/table.c b/src/table.c
index 140e8c8..85cf631 100644
--- a/src/table.c
+++ b/src/table.c
@@ -550,7 +550,7 @@ _vte_table_extract_numbers(GValueArray **array,
 		if (G_UNLIKELY (*array == NULL)) {
 			*array = g_value_array_new(1);
 		}
-		g_value_set_long(&value, total);
+		g_value_set_long(&value, CLAMP (total, 0, G_MAXUSHORT));
 		g_value_array_append(*array, &value);
 	} while (i++ < arginfo->length);
 	g_value_unset(&value);
diff --git a/src/vteseq.c b/src/vteseq.c
index 457c06a..46def5b 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -557,7 +557,7 @@ vte_sequence_handler_multiple(VteTerminal *terminal,
                               GValueArray *params,
                               VteTerminalSequenceHandler handler)
 {
-        vte_sequence_handler_multiple_limited(terminal, params, handler, G_MAXLONG);
+        vte_sequence_handler_multiple_limited(terminal, params, handler, G_MAXUSHORT);
 }
 
 static void
--
cgit v0.9.0.2
patch?id=f8d8109369c6a70e69010a2522207302c73d2123'>commit</a><a class='active' href='/guix/diff/gnu/packages/patches/libmhash-hmac-fix-uaf.patch?id=f8d8109369c6a70e69010a2522207302c73d2123'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/gnu/packages/patches/libmhash-hmac-fix-uaf.patch'>
<input type='hidden' name='id' value='f8d8109369c6a70e69010a2522207302c73d2123'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/guix/diff/?id=f8d8109369c6a70e69010a2522207302c73d2123'>root</a>/<a href='/guix/diff/gnu?id=f8d8109369c6a70e69010a2522207302c73d2123'>gnu</a>/<a href='/guix/diff/gnu/packages?id=f8d8109369c6a70e69010a2522207302c73d2123'>packages</a>/<a href='/guix/diff/gnu/packages/patches?id=f8d8109369c6a70e69010a2522207302c73d2123'>patches</a>/<a href='/guix/diff/gnu/packages/patches/libmhash-hmac-fix-uaf.patch?id=f8d8109369c6a70e69010a2522207302c73d2123'>libmhash-hmac-fix-uaf.patch</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='f8d8109369c6a70e69010a2522207302c73d2123'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><div class='diffstat-header'><a href='/guix/diff/?id=f8d8109369c6a70e69010a2522207302c73d2123'>Diffstat</a> (limited to 'gnu/packages/patches/libmhash-hmac-fix-uaf.patch')</div><table summary='diffstat' class='diffstat'></table><div class='diffstat-summary'>0 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td></td></tr></table></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
