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 - 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
-
-
-
-
(Locked)
Formatting preprocessor directives1m 33s
-
(Locked)
Using an assignment as a condition1m 44s
-
(Locked)
Avoiding putchar() in a while loop2m 38s
-
(Locked)
Using the system() call2m 4s
-
(Locked)
Accessing elements beyond the array size2m 38s
-
(Locked)
Converting integers2m 57s
-
(Locked)
Looping with floating point values3m 10s
-
(Locked)
Using return values1m 52s
-
(Locked)
Confirming when EOF has been read3m 34s
-
(Locked)
Challenge: Fix the code1m 20s
-
(Locked)
Solution: Fix the code1m 54s
-
(Locked)
-
-
-
-