Article Index

Delete Memo

 

Checking out delete menu. Let's try the following cases:

 

  1. Index that we have created a memo on (legit case)
  2. Index that we have not created a memo on
  3. Negative Index
  4. Large positive index
  5. Double delete

 

Index we've created a memo on

>> 4
Index: 0
Deleted!

 

Index we have not created a memo on

>> 4
Index: 2
there isn't message

 

Negative Index

>> 4
Index: -1
there isn't message

 

Large Positive Index

>> 4
Index: 65536
Segmentation fault (core dumped)

 

 

Double delete

>> 4
Index: 0
Deleted!

1. Leave message on memo
2. Edit message last memo
3. View memo
4. Delete memo
5. Change password
6. Quit.
>> 4
Index: 0
there isn't message=

 

We're getting a segfault when we delete a large index, but no error aside from "no message" when we delete negative. With those in mind, let's look at the code.

 

 

The beginning is the same as others. Note that it does cdqe, so we can put in negative numbers and have it subtract instead of add large numbers. It dereferences whatever is at that index and checks if it's already zero. Note, there's no bounds checking here, so this is why you get a segfault on a large number (it runs off the page).

 

If the entry is non-zero (not really checking for a valid pointer, it will free the pointer that's in that array and zero out the array slot. Not much else going on here.