s can prevent a lot of application weaknesses from becoming exploitable vulnerabilities. Standard software development guidelines are defined (for example) by MISRA for C-programming for specifically embedded systems. Tools such as Coverity can analyze software and flag typical errors such as buffer overflow but are often ignored under software delivery pressures. Topics include Applications use memory to store transient data on the stack and heap. Care must be taken to prevent programs from reading from or writing to invalid memory addresses. Memory that was allocated to programs must be released to the os properly to prevent vulnerabilities. Memory that was de-allocated must not be accessed by the program anymore. A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. Denial-of-service can occur when a program allocates memory for a certain action but never releases it to the OS. If there are random values that must be generated, it is important that these values are not predictable. So, make sure that all random values are generated with a sufficiently secure random number generator, either in software or a hardware accelerator/external security processor. Buffer overflow and underflow conditions should be managed. A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold or Chapter 5 System software 211 use pointers to memory that has not been allocated to the program (anymore). Writing outside the bounds of the allocated memory can corrupt data, crash the program, or cause the execution of malicious code. Attackers might exploit such conditions by supplying tainted input to the program. The program overwriting data after the end of the memory buffer (which can include the return address of the calling function) or before the start of the memory buffer. The program reading data after the end of the memory buffer or before the start of the memory buffer. If the appl