[hackers] [libutf] charntorune: avoid potential 32 bit overflow || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Sat, 26 May 2012 01:29:58 +0200 (CEST)

changeset: 18:0d20cefaf2b4
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Sat May 26 00:29:55 2012 +0100
files: rune.c
description:
charntorune: avoid potential 32 bit overflow


diff -r e6d19685f06e -r 0d20cefaf2b4 rune.c
--- a/rune.c Mon May 21 19:04:16 2012 +0100
+++ b/rune.c Sat May 26 00:29:55 2012 +0100
_AT_@ -81,13 +81,13 @@
                         return i;
                 }
                 else
- r = (r << 6) | (s[i] & 0x3F);
+ r = (r << 6) | (s[i] & 0x3F); /* 10xxxxxx */
 
         if(i < n) /* must have reached len limit */
                 return 0;
 
         /* reject invalid runes and overlong sequences */
- if(n > UTFmax || runelen(r) < (int)n || BADRUNE(r))
+ if(n > 4 || runelen(r) < (int)n || BADRUNE(r))
                 r = Runeerror;
 
         *p = r;
Received on Sat May 26 2012 - 01:29:58 CEST

This archive was generated by hypermail 2.3.0 : Sat May 26 2012 - 01:36:06 CEST