There’s no such thing as a perfect solution

I’m still trying to find a way to deal with the problem of assigning Canadian waypoints to their correct province. The first thing I did was grab George Plews Airports In Canada data file, which as well as giving me hundreds of new airports that I didn’t have already, also made sure that all my airports were in the right province. But I’ve still got problems.
Continue reading “There’s no such thing as a perfect solution”

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.

That’s your job, isn’t it?

Our company has a translation group. Normally we send off our properties files, and we get back the versions for the languages we support in this application. Sometimes we get a few questions from the translators, usually just a clarification of how we’re using a term or a request for some context. I send back and answer, and a few days later I get my translation.

I don’t think their Chinese translator quite understands this process though. I got back a list of translator questions from him, and it’s all stuff like “Please confirm this translation of the string ‘Foo Bar'” followed by a string of Chinese characters. Or “Should the word ‘Digest’ be translated or left as English?” I feel like writing back and saying “HOW THE FUCK SHOULD I KNOW? YOU’RE THE ONE WHO CAN SPEAK CHINESE!” But I won’t. Instead I’m writing to his manager to explain that we can’t answer his questions because we don’t speak Chinese, and leaving out the part about how if we did speak Chinese we wouldn’t need them.

Forgot my mind reading device again

You know, if you’re going to send email to a person who runs a mailing list, don’t assume that he only runs one mailing list. Generally the skills for running one list are transferrable to other mailing lists, so the person in question might run more than one. Take me, for instance. I run probably 2 dozen or so lists. Which is why I get so annoyed when I get email like this:

To whom this may concern:

I am from [Clueless Wankertech] Inc. and we have an event coming up that we feel
the members of your mailing list will benefit from. Below is a post
which we are wondering if you could post to your mailing list or allow
us to do this. Thank you for your time and consideration.

The post is as follows:

WordPress plugins

Every now and then, the WordPress OpenID comment plugin I use goes mental and starts taking people’s comments and posting them to a non-existant post, and also stripping out all the text of their comments. I suspect it’s an interaction with SpamKarma2 and/or Akismet, but there is no way I’m going to do without spam protection, so I guess at times like this, my only option is to deactivate the OpenID plugin.

So sorry pir and jdev, but your comments were lost. Please feel free to submit them again.