Jump to content

User:Exx8/sandbox/stackoverflow

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Exx8 (talk | contribs) at 17:36, 15 December 2020 (Created page with '{| class="wikitable" style="width:32em; text-align:center;" ! style="white-space:nowrap;" | variable name ! colspan=8 style="background:#ddf;" | A ! colspan=2 st...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
variable name A B
value [null string] 1979
hex value 00 00 00 00 00 00 00 00 07 BB

Now, the program attempts to store the null-terminated string "excessive" with ASCII encoding in the A buffer.

strcpy(A, "excessive");

"excessive" is 9 characters long and encodes to 10 bytes including the null terminator, but A can take only 8 bytes. By failing to check the length of the string, it also overwrites the value of B:

variable name A B
value 'e' 'x' 'c' 'e' 's' 's' 'i' 'v' 25856
hex 65 78 63 65 73 73 69 76 65 00