Gitweb links:

...log 
http://git.netsurf-browser.org/libcss.git/shortlog/1d52e081bc36edef3f8503fae18db0291b186c68
...commit 
http://git.netsurf-browser.org/libcss.git/commit/1d52e081bc36edef3f8503fae18db0291b186c68
...tree 
http://git.netsurf-browser.org/libcss.git/tree/1d52e081bc36edef3f8503fae18db0291b186c68

The branch, master has been updated
       via  1d52e081bc36edef3f8503fae18db0291b186c68 (commit)
       via  a0fcc8e5dee6f61c12ce44503edd26e699d5e663 (commit)
       via  f4e28a9fbd87f652c1e1428f5c576786b41d4f10 (commit)
      from  21955293e6769732a671d700e3b3862dd6c3a901 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=1d52e081bc36edef3f8503fae18db0291b186c68
commit 1d52e081bc36edef3f8503fae18db0291b186c68
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Parsing: Fix undefined shift in css__parse_hash_colour.
    
    uint a = 0xff;
    a << 24
    
    `a` gets promoted to int, which can't store the value.
    
    src/parse/properties/utils.c:655:16: runtime error: left shift of 255 by 24 
places cannot be represented in type 'int'
    src/parse/properties/utils.c:889:15: runtime error: left shift of 255 by 24 
places cannot be represented in type 'int'

diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 76b406b..7abef24 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -652,7 +652,7 @@ css_error css__parse_colour_specifier(css_language *c,
                        goto invalid;
                }
 
-               *result = (a << 24) | (r << 16) | (g << 8) | b;
+               *result = ((unsigned)a << 24) | (r << 16) | (g << 8) | b;
        }
 
        *value = COLOR_SET;
@@ -886,7 +886,7 @@ css_error css__parse_hash_colour(lwc_string *data, uint32_t 
*result)
        } else
                return CSS_INVALID;
 
-       *result = (a << 24) | (r << 16) | (g << 8) | b;
+       *result = ((unsigned)a << 24) | (r << 16) | (g << 8) | b;
 
        return CSS_OK;
 }


commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=a0fcc8e5dee6f61c12ce44503edd26e699d5e663
commit a0fcc8e5dee6f61c12ce44503edd26e699d5e663
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Tests: Fix undefined behaviour in css_fixed printing.
    
    test/number.c:137:22: runtime error: negation of -2147483648 cannot be 
represented in type 'int'; cast to an unsigned type to negate this value to 
itself

diff --git a/test/number.c b/test/number.c
index d255f4c..7b0d10f 100644
--- a/test/number.c
+++ b/test/number.c
@@ -133,7 +133,7 @@ void run_test(const uint8_t *data, size_t len, const char 
*exp, size_t explen)
 
 void print_css_fixed(char *buf, size_t len, css_fixed f)
 {
-#define ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
+#define ABS(x) (uint32_t)((x) < 0 ? -((int64_t)x) : (x))
        uint32_t uintpart = FIXTOINT(ABS(f));
        /* + 500 to ensure round to nearest (division will truncate) */
        uint32_t fracpart = ((ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);


commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=f4e28a9fbd87f652c1e1428f5c576786b41d4f10
commit f4e28a9fbd87f652c1e1428f5c576786b41d4f10
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    css_fixed: Avoid undefined shift.
    
    From undefined behaviour sanitizer:
    
      src/utils/utils.c:130:18: runtime error: left shift of negative value -1

diff --git a/src/utils/utils.c b/src/utils/utils.c
index 4bd93f6..64409eb 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -127,6 +127,6 @@ css_fixed css__number_from_string(const uint8_t *data, 
size_t len,
                }
        }
 
-       return (intpart << 10) | fracpart;
+       return ((uint32_t)intpart << 10) | fracpart;
 }
 


-----------------------------------------------------------------------

Summary of changes:
 src/parse/properties/utils.c |    4 ++--
 src/utils/utils.c            |    2 +-
 test/number.c                |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 76b406b..7abef24 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -652,7 +652,7 @@ css_error css__parse_colour_specifier(css_language *c,
                        goto invalid;
                }
 
-               *result = (a << 24) | (r << 16) | (g << 8) | b;
+               *result = ((unsigned)a << 24) | (r << 16) | (g << 8) | b;
        }
 
        *value = COLOR_SET;
@@ -886,7 +886,7 @@ css_error css__parse_hash_colour(lwc_string *data, uint32_t 
*result)
        } else
                return CSS_INVALID;
 
-       *result = (a << 24) | (r << 16) | (g << 8) | b;
+       *result = ((unsigned)a << 24) | (r << 16) | (g << 8) | b;
 
        return CSS_OK;
 }
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 4bd93f6..64409eb 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -127,6 +127,6 @@ css_fixed css__number_from_string(const uint8_t *data, 
size_t len,
                }
        }
 
-       return (intpart << 10) | fracpart;
+       return ((uint32_t)intpart << 10) | fracpart;
 }
 
diff --git a/test/number.c b/test/number.c
index d255f4c..7b0d10f 100644
--- a/test/number.c
+++ b/test/number.c
@@ -133,7 +133,7 @@ void run_test(const uint8_t *data, size_t len, const char 
*exp, size_t explen)
 
 void print_css_fixed(char *buf, size_t len, css_fixed f)
 {
-#define ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
+#define ABS(x) (uint32_t)((x) < 0 ? -((int64_t)x) : (x))
        uint32_t uintpart = FIXTOINT(ABS(f));
        /* + 500 to ensure round to nearest (division will truncate) */
        uint32_t fracpart = ((ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);


-- 
Cascading Style Sheets library

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to