[yelp] Avoid possible overrun while comparing to MAN_FONTS



commit 8b2fab2978b90757d927010dd1faa2840a4e7f07
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Jul 23 11:30:54 2018 +0200

    Avoid possible overrun while comparing to MAN_FONTS
    
    yelp-3.28.1/libyelp/yelp-man-parser.c:464: cond_at_most: Checking "k > 8U" implies that "k" may be up to 
8 on the false branch.
    yelp-3.28.1/libyelp/yelp-man-parser.c:469: overrun-local: Overrunning array "parser->font_registers" of 8 
8-byte elements at element index 8 (byte offset 64) using index "k" (which evaluates to 8).
    
    yelp-3.28.1/libyelp/yelp-man-parser.c:476: assignment: Assigning: "k" = "parser->current_font".
    yelp-3.28.1/libyelp/yelp-man-parser.c:477: cond_at_most: Checking "k > 8U" implies that "k" and 
"parser->current_font" may be up to 8 on the false branch.
    yelp-3.28.1/libyelp/yelp-man-parser.c:477: overrun-local: Overrunning array "parser->font_registers" of 8 
8-byte elements at element index 8 (byte offset 64) using index "k" (which evaluates to 8).

 libyelp/yelp-man-parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libyelp/yelp-man-parser.c b/libyelp/yelp-man-parser.c
index 8d097820..00e66e00 100644
--- a/libyelp/yelp-man-parser.c
+++ b/libyelp/yelp-man-parser.c
@@ -463,7 +463,7 @@ yelp_man_parser_free (YelpManParser *parser)
 static void
 set_font_register (YelpManParser *parser, guint k, const gchar* name)
 {
-    if (k > MAN_FONTS) {
+    if (k >= MAN_FONTS) {
         g_warning ("Tried to set nonexistant font register %u to %s",
                    k, name);
         return;
@@ -476,7 +476,7 @@ static const gchar*
 get_font (const YelpManParser *parser)
 {
     guint k = parser->current_font;
-    if (k > MAN_FONTS ||
+    if (k >= MAN_FONTS ||
         parser->font_registers[k] == NULL) {
 
         g_warning ("Tried to get nonexistant font register %u", k);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]