c requires you to do things like define the maximum length of a string. In fact a string in c is literally defined as an array of characters. There are no protections in c, so you can define a string to be 10 characters long and then copy 20 characters to it. The result is most often a stack overflow that immediately crashes the program.
This was legacy code that was likely written in the early days of DOS before things like Microsoft Windows existed, so memory usage was still pretty important. Whoever wrote this code tried to calculate the maximum size of a string used to print a header in this reporting package as a way to optimize memory usage. But they were off by one character. So when the code created a header with a date containing the longest month name, the longest date name, and a two digit day of the month, then that string overflowed and crashed the program.
Comments
c requires you to do things like define the maximum length of a string. In fact a string in c is literally defined as an array of characters. There are no protections in c, so you can define a string to be 10 characters long and then copy 20 characters to it. The result is most often a stack overflow that immediately crashes the program.
This was legacy code that was likely written in the early days of DOS before things like Microsoft Windows existed, so memory usage was still pretty important. Whoever wrote this code tried to calculate the maximum size of a string used to print a header in this reporting package as a way to optimize memory usage. But they were off by one character. So when the code created a header with a date containing the longest month name, the longest date name, and a two digit day of the month, then that string overflowed and crashed the program.
Sign in to comment. Sign in