Today’s “Little Bobby Tables” Moment

Ever told yourself “oh, I don’t have to sanitize the input because I’m the only person using it” only to have it bite you in the ass?

When I’m loading waypoint data into my database, I calculate the magnetic declination of each point using a program that I got years ago and hacked the hell out of. I call it magvar, because declination is sometimes (incorrectly) called “magnetic variation” and I didn’t know any better when I did it. The program as it was written prompted for input (latitude, longitude, elevation and date) one number at a time, validated it, parsed the World Magnetic Model (WMM) data file, and told you the declination and a bunch of other stuff about the location. Well, I needed it to be faster than that, so I had it pre-parse the WMM file, then it sat there in a loop where it did a "sscanf" of the four input numbers (C programmers are now shuddering in horror), and printed the output, and then my perl script did an "open2" to open a pipe to write the four numbers on, and another pipe to read the result. And that’s worked pretty well up until today.

Today I was loading some new datasource, and I noticed that about 75% of the way through, it was hanging. And it appeared to be hanging in the write to the magvar program’s input pipe. I tried commenting out the call, and it ran fine, but of course it didn’t have any declinations. So I put the call back in and ran it again. And then attached to the executable with gdb (some old atrophied skills suddenly got refreshed in memory). And that’s where I discovered that the program seemed to be stuck in a write. And going up a few levels into the code that I’d touched and dumping the local variables, the input latitude and longitude seemed to be indicating a waypoint that was one of the first ones input. That’s when I had another look at the data I was feeding the program. And that’s where I discovered instead of writing 4 doubles that scanf could happily read using "%lf %lf %lf %lf", I hadn’t noticed that on some of the waypoints in this new datasource, the elevation was given as "apprx 123". I didn’t bother to look in detail what happened at this point, but I assume my unchecked input caused the magvar program to go into an infinite loop, spewing out the same declination value over and over onto the perl program’s input pipe until the pipe filled up.

And I haven’t learned my lesson – I have no plans to fix magvar to validate its input. I’m just going to make sure this particular data loader program does a
$elev =~ s/\s*apprx\s*//;
before calling it.

Today’s iPod discovery

I’ve had this iPod since April. (One thing this blog is good for is that I can use it to check on the petty details of my life.) All this time I’ve had it in an incase leather case, which puts a rubber membrane on top of the scroll wheel. That membrane kind of slows down the scrolling, so I usually use the new “Search” function because scrolling through however many hundreds of artists or thousands of albums to find the one that’s been running through my head all night is too damn slow. But today I took it out of the case for some reason, and something amazing happened. I was scrolling though the list of artists, and suddenly I got a gigantic “A” in the middle of the screen, and each tick of the scroll wheel moved one letter instead of just one album. Once I got to the first letter of the artist I wanted (Captain Tractor, btw), I paused and it went back to slow scrolling through the individual items. This is very cool – it really speeds up scrolling to where I want. Once again, Apple pleasantly surrprises me with user interface delight.

Now if only they’d make it so that going fast goes to scrolling through the first letters, then one quick pause and you’re in quick scrolling through second letters, and such.

Google gets their collective fingers out

Well, only four months late, but I finally got the check I’ve been waiting for from Google.

See:
Rants and Revelations » Oh Google, you are so devoid of any semblance of clue and
Rants and Revelations » Hey, Google for previous ranting about this subject.

I won’t rant about the fact that they only allow $30 a day for meal expenses, and my breakfast in the hotel cost more than that. Nope, I won’t.

Sniff, sniff. Good bye old friend.

My favourite airplane, our club’s Piper Lance, is up for sale on eBay Motors:

eBay Motors: 1977 Piper Lance PA-32-300R – Great Buy, Flies Often! (item 140161831797 end time Oct-14-07 17:00:00 PDT)

Personally I think the reserve is too high, but I think they’re just trying to find out what the market will really bear. It looks like the only bidders so far are dealers bidding less than half what it’s really worth, looking for a totally desperate seller, and we’re not there yet.

But the plane’s annual is due in December, and we were told last year that the engine probably won’t pass another annual, and there just aren’t enough club members willing to pay the surcharge to justify spending the money for an engine and prop overhaul. So this plane is going to get sold, somehow.

So good bye, old friend. I’ll miss your speed, your load capacity, and your outstanding interior room. But mostly I’ll miss the fact that it felt like a good solid honest plane.