billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=c2dd1815c8873690c249545c64cf288359b40afb

commit c2dd1815c8873690c249545c64cf288359b40afb
Author: Boris Faure <[email protected]>
Date:   Thu Jul 2 23:45:32 2020 +0200

    termptyesc: avoid issues with cast from double
    
    + no buffer overflow
---
 src/bin/termptyesc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 76e0991..ea3e4df 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -3771,7 +3771,7 @@ _xterm_parse_intensity(Eina_Unicode *p, unsigned char *c, 
int len)
    char *endptr_double;
    double d;
 
-   while (l < 64 && len && p[0] && p[0] != '/' && p[0] != '\007' && p[0] < 128)
+   while (l < 63 && len && p[0] && p[0] != '/' && p[0] != '\007' && p[0] < 128)
      {
         buf[l++] = p[0];
         len--;
@@ -3785,7 +3785,11 @@ _xterm_parse_intensity(Eina_Unicode *p, unsigned char 
*c, int len)
    if (endptr_double == buf || d < 0 || d > 1.0 || isnan(d))
        return -1;
 
-   *c = d * 255.0;
+   d *= 255.0;
+   if (d > 255.0)
+     *c = 255;
+   else
+     *c = round(d);
    return endptr_double - buf;
 }
 

-- 


Reply via email to