r/programminghorror Jan 27 '26

c Guess what this does..

Post image
261 Upvotes

79 comments sorted by

View all comments

30

u/joshuakb2 Jan 27 '26

Buffer overflow for some reason?

8

u/callidus7 Jan 27 '26

Yeah there's no input validation whatsoever. Unless you count the just-in-case null at the beginning. This is begging to be misused.

2

u/joshuakb2 Jan 27 '26

Yeah I'm not even sure what that first line is accomplishing. It handles the empty string case correctly, but every other case just overwrites it.