avrdude-dev
[Top][All Lists]
Advanced

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

[patch #9820] Fix some out-of-bounds/uninitialized issues


From: Joerg Wunsch
Subject: [patch #9820] Fix some out-of-bounds/uninitialized issues
Date: Thu, 10 Sep 2020 17:24:56 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:69.0) Gecko/20100101 Firefox/69.0

Follow-up Comment #1, patch #9820 (project avrdude):

Regarding the divide by 0 patch, I think the following patch is more
versatile:

Index: avrpart.c
===================================================================
--- avrpart.c   (revision 1435)
+++ avrpart.c   (working copy)
@@ -254,6 +254,7 @@
   }
 
   memset(m, 0, sizeof(*m));
+  m->page_size = 1; // ensure not 0
 
   return m;
 }
Index: config_gram.y
===================================================================
--- config_gram.y       (revision 1435)
+++ config_gram.y       (working copy)
@@ -1310,7 +1310,11 @@
 
   K_PAGE_SIZE       TKN_EQUAL TKN_NUMBER
     {
-      current_mem->page_size = $3->value.number;
+      int ps = $3->value.number;
+      if (ps <= 0)
+        avrdude_message(MSG_NOTICE, "invalid page size %d, ignored", ps);
+      else
+        current_mem->page_size = ps;
       free_token($3);
     } |
 


This ensures the page size is always at least 1, so any modulo operation with
it will work - regardless of where it happens.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9820>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]