How it works...
We want to enter information about the customer's name and the order placed by them. So, we define a structure called users with two members, name and orderid, where the name member is defined as a character array of length 10 bytes, and the orderid member is defined of the int data type consisting of 2 bytes. A variable, user1, is defined of the users structure type, hence the user1 structure will get two members, name and orderid. An integer of value 101 is assigned to the orderid member of the user1 structure.
Using the sprintf function, a string, bintuharwani, is assigned to the name member of the user1 structure. The bintuharwani string is larger than the name member, hence a buffer overflow will occur, overwriting the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access