From the course: Secure Coding in C

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Challenge: Fix the code

Challenge: Fix the code - C Tutorial

From the course: Secure Coding in C

Challenge: Fix the code

(upbeat electronic music) - [Instructor] For this challenge, I present you with this code included with the exercise files. The code compiles and it runs. (keys clicking) That's it. We can verify the file's contents. Of course, the file is not created in the current directory, so we have to go to chapter two, and then change to this folder, 02_10, list the output, and we can cat the challenge.txt file. There's the text I input. It seems like everything works. Yet I've place eight undefined behavior issues into this code that you must find, plus one bonus issue. These items are mentioned in this course, and they should be addressed to make this code run safe and in a predictable manner. Your task is to find and correct the various issues found in the exercise file. Modify the code as necessary, adding or removing statements, changing items, make it safe, and remove any undefined behaviors. Keep working with the code until you find and correct as many of the eight issues as possible…

Contents