buggperf - Bugs: bug #43982, Invalid memory access with --pic...

 
 

bug #43982: Invalid memory access with --pic option

Submitted by:  None
Submitted on:  Mon 12 Jan 2015 01:08:51 AM UTC  
 
Category: Generated codeSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: Bruno Haible <haible>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 25 Nov 2016 07:42:17 PM UTC, comment #1:

The code snippet that you showed (with a comparison via 'memcmp') is generated only with option -l, and then it looks like this:

The code first makes sure that len > 0.
Then it computes the hash code.
Then it proceeds only when len == lengthtable[key], which implies that lengthtable[key] > 0 (since we already know that len > 0), which implies that the hash table entry exists (since the non-existing entries have a length 0 assigned in the lengthtable).

Similarly, when gperf option -l is used together with -D

In this case the index has been validated because it's an non-negative element of the 'lookup' table.

So there is no bug.

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Mon 12 Jan 2015 01:08:51 AM UTC, original submission:

With the --pic option, the keyword slot is set to -1 for non-existing hash table entries. This can result in a memory access outside of the string pool in the following piece of generated code:

register const char *s = wordlist[key].keyword + stringpool;

if (str == s && !memcmp (str + 1, s + 1, len - 1))
return &wordlist[key];

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by haible (Updated the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 25 Nov 2016 07:42:17 PM UTChaibleStatusNone=>Invalid
      Assigned toNone=>haible
      Open/ClosedOpen=>Closed
    Thu 24 Nov 2016 12:08:25 AM UTChaibleCategoryNone=>Generated code

    Back to the top


    Powered by Savane 3.1-cleanup1