28 July 2008

Don't forget about Lint

The lint utility that is supplied with Sun Studio 12 has some great features for analysing and diagnosing source code problems. Lint is a static source code analyser, but has large fallen out of fashion due to developers relying on compiler diagnostics.

Indeed, having your source run on a variety of UNIX platforms is a great way to uncover issues. I regularly have to compile the same code on Solaris, RedHat AS 5, Ubuntu, Debian, HP-UX, HP-UX Itanium & AIX.

The various compilers do have excellent warnings and that's worth exploring as a project, some of them have great 64-bit checking options.

Sun Studio Lint has some wonderful options for diving into your source code to do that extra thorough analysis. It can uncover 64-bit porting problems and something I didn't know, was that it can try to find security problems also.

Example output:

(34) warning: possible ptrdiff_t overflow
(242) warning: format argument to sprintf() contains an unbounded string specifier
(252) warning: format argument to sprintf() contains an unbounded string specifier
(319) warning: possible ptrdiff_t overflow
(324) warning: possible ptrdiff_t overflow

So it can detect the following potential problem :
"Use the -errsecurity option to check your code for security loopholes."

char buffer[80];

sprintf( buffer, sizeof(buffer)-1, "%c%d%d%s%d", ch, i1, i2, filename, i3 );


where it's saying that the filename string isn't limited and could overrun the buffer. One fix would be to change to use "%.*s" rather than "%s".

Sun Studio docs for Lint

10 July 2008

OpenSolaris 2008.05 ISOs To Be Updated

It looks like the ISOs are to be updated soon, that's great news. I hope it improves it a lot. I am using Ubuntu 8.04 64-bit and it is really good, but living without a good developer environment like SunStudio and great tools like DTrace is really difficult. Java JNI debugging on Linux is almost impossible, it's a dream on Solaris. I hope to download the later ISOs and reinstall the OS.
But using Ubuntu 8.04 64-bit has been a good experiment at work, it's good to not have to put up with Windows.

Phoronix: OpenSolaris 2008.05 ISOs To Be Updated