Sunday, August 7th, 2011
Today I encountered a bug that was quite difficult to find regarding strings. In order for strings to work they must be null-terminated, and this implies that an array of characters can contain a string with a length equal to the array size minus one, because there must be space for the null character. I found out that, when initializing array of chars with strings, the compiler does not complain if just the null character doesn’t fit.
(more…)
Tags:buffer overflow, bug, c, null terminated, overflow, splint, static analysis, strings
Posted in C, Guest Posts, Programming | 1 Comment »
Saturday, November 28th, 2009
It’s often a good strategy when developing software to ensure that a number of compiler warnings are switched on. For example, the GCC compiler flag ‘-Wall‘ is often used to provide warnings about all ‘questionable constructions’ (things like omitting to include a return statement in a function that should return a non-void type). Enabling warnings such as this can speed up development as more time is spend debugging application logic rather than silly errors. However the downside is that the compiler may provide warnings about things that we know about and are happy with. This post revisits GCC attributes to see how we can supress such warnings.
(more…)
Tags:-Wno-unused-parameter, -Wunused-parameter, attribute, compiler, compiler-gcc3.h, compiler.h, GCC, gcc attribute, unused, unused parameter, wall, warnings
Posted in C | 3 Comments »