defensive programming

BBC NEWS | Technology | ‘Critical’ flaw found in Windows

Microsoft has issued a warning about a critical security flaw that affects most versions of its Windows software.
[ . . . ]
The flaw, found by eEye Security, would allow a specially crafted MIDI instruction to swamp the cache, or buffer, in DirectX and allow a hidden program within it to run on the target machine.

Such buffer overflow bugs are quite a common way for malicious programs to infect a machine.

Microsoft has issued an alert about the flaw and a patch to close the loophole. It said that currently there were no known exploits of the bug.

The instruction could get into a computer by being put on a webpage.

It can also be put into an e-mail message that uses web formatting.

Secure C Programming

Buffer Overflows
A buffer overflow is what happens when programs try to store more data in a variable than it has been allocated space for. For example, suppose you have a variable called name that’s defined as an array of 10 characters. There is room for 9 characters, plus the terminating null. By default, C does no bounds checking at run-time, so it is very easy for the user of a badly written program to over flow a buffer. Consider this code fragment:

char name [10];
printf ("Enter your name: ");
fflush (stdout);
gets (name);


If the user of this program enters a name that’s less than 10 characters, all is well. But if they enter a longer string, the stack will get stomped on and data corruption can occur, causing a core dump, or worse, giving the user shell prompt. If the program is running as root, this would be disastrous.

So what can you do to avoid these buffer overflow problems? One answer is to provide really big buffers that “no one will ever overflow”. This is a bad idea because it hasn’t fixed the problem; it merely makes it harder to accidentally overflow the buffer. But it won’t stop a malicious user from deliberately overflowing the buffer. To do that, you need to use functions that let you specify a maximum number of characters to copy. If you change the line that reads

gets (name);
to
fgets (name, 10, stdin);

it doesn’t matter how many characters the user types in response to the prompt, as only the first 9 characters will be copied into the variable name. (With this example, you also have to remove the n character from the end of the name, as fgets() doesn’t remove it.)

This is, literally, what you learn in a 1st quarter programming class, especially if you learn C or C++. Given no bounds-checking or other safety harnesses, it’s up to the programmer to verify with test cases that his code can’t be misused or exploited by either a naive or cunning end-user, person or process. A Google search for “profiling+tools+buffer+overflow+bounds+checking” turns up some research and tools on this topic.

The fact this bug is in Windows Server 2003 suggests those much-discussed code reviews aren’t being taken all the seriously.

your own radio station

O’Reilly Network: Unsung Heros and Other iTunes Tips [July 31, 2003]

[ . . . . ] there’s a lot of good music on my iPod that I just don’t seem to get to. And that’s a waste.

[ . . . . ] So I created a new smart playlist titled “Unsung Heros.” In the parameters for the list I set Last Played -> is not in the last -> 30 days, and then I set up a couple more limiters such as Album -> does not contain -> Christmas so Bing Crosby doesn’t constantly appear at the top of my list. One other parameter I set is Limit to 50 songs -> selected by song name.

But not like this:

BBC NEWS | Technology | UK bans iPod gadget

A N Micro, the UK distributor of the iTrip, said use of the device was prohibited under the Wireless Telegraphy Act of 1949.

one of everything? no problem

Public Project

Welcome to Browser Cam!
Browser Cam creates screen captures of your web pages loaded in any browser, and on any operating system, so you’ll be 100% sure your web pages look good-and work right-on any platform.

I used the free trial today to see what some new things I was trying would look like. I discovered the fieldset CSS tag and decided to redo a page with a form to take advantage of it. In most cases, it looks fine, only irretrievably broken in IE5.5 (it crashes?!), but it is disappointing that the 1 px rule around the form and around the legend only renders in KHTML-based browsers and even there not uniformly. Sadly, IE5’s violent reaction means I can’t use it.

art is what people will buy

BW Online | July 30, 2003 | Why iTunes Has Bands on the Run

At the heart of the debate is this question: Who should decide what’s art, the artist or the public? The Chili Peppers and Metallica say they — and they alone — should decide how fans should listen to and keep their music.


[ . . . . ] Apple’s (APPL ) iTunes is a tool of liberation. It gives them the freedom to pick and choose, and, in essence, make their own compilations from favorite tracks. [ . . . ] In fact, the opportunity to compile personalized play lists and track selections may be one of the service’s biggest draws.

bookmarked: compendium of 3 column CSS layouts

Three Column Layouts – css-discuss

The question of finding good 3 column layouts comes up in the mail list from time to time. Here are some that I have found, along with a few notations about what features they include and how they work. The judgement of “good” is left to you and your needs. Each offers interesting techniques for the CSS student. By the way, when visiting these places, look around; many of these people offer other layouts that I have not included here.

Very nice to find all these, instead of partially re-inventing them, badly.

why go where you’re not wanted? Why not?

MacMerc.com: BuyMusic blocks Mac, but we have a hack

BuyMusic.com (the site that ripped off the apple store), just started to block all Mac users. I don’t know about you, but I can’t stand when I can’t see something (not that I want to, it’s just the concept). Here’s what you do if you want to be able to view the site in Safari.

Open the terminal and copy/paste:

defaults write com.apple.Safari IncludeDebugMenu 1


If Safari is open, quit it and restart. Otherwise just open it up. Now look at the menu bar at the top right. It should read “debug”, and you’re right if you think it’s new. Click it and go down to “User Agent” and then hit Windows MSIE 6. That’s it. Go check out those crazy cats at BuyMusic!

yours truly, trademark violator?

There Is No Cat – Adventures in The Trademark Zone

Did you know that Clue-by-Four[tm] is a trademarked term?

Apparently, I’m an offender as well, but I had never heard the term used before: it just stemmed from my exasperation at that moment.

Here’s the link to the USPTO details. This guy’s going to a lot of trouble to defend his foam rubber board. There’s a metaphor there that I’m not going to touch . . . .

plugins falling by the wayside

I find I’m gradually shedding Movable Type plugins. I never got the Blogshares plugin to work properly, so I gave up on it. I had to remove the WayPath plugin: my machine is so underpowered it could never complete a rebuild of new pages, so publishing was blocked. I’m shopping for some RAM to alleviate that problem. And then the other day, the Technorati plugin started barfing on something, so out it came.

The Backlinks cgi is too simple *not* to work, so it wil stay for now.

first ride on new wheels

I got up early today and was on the road at 6:20, ending up with 40 miles on this first ride. Not very enjoyable. I couldn’t find a comfortable cadence or position, so some saddle adjustments are needed. I also gave in and bought some gloves to shield my hands from further nerve damage: I have sustained some minor damage to the median and ulnar nerves where they enter the palm of my hand and I’d like to minimize it.

Ran into a couple of riders who did the STP this year: first-timers both of them and they did the one day ride in 11 hours 47 minutes. Works out to about 17 miles per hour.

My new cyclometer seemed OK when I tested it, but the cadence counter — the chief reason for choosing it — wouldn’t work today. Very annoying. The speed and distance sensor worked just fine, so I don’t know what’s up with it.

where do you belong?

I’m reading The Nine Nations of North America, a book I remember being talked about when I left high school, but for various reasons, never looked up.

It’s quite interesting: while it’s not a scholarly book (no footnotes and somewhat breezy prose), it builds on factual observations and real statistics to make the case that the continent of North America is not made of three countries as the maps show, but nine, based on ideologies, economics, and regional/national interests. It may be a stretch to call a nation what’s commonly regarded as a region, but not that much of one: I think there’s a stronger sense of self in these region/nations than in others in, say, France or England.

The nations are (roughly: I’d like to find a map on the web, but this will do):

  • New England, similar to what we refer to now, with the addition of the Canadian Maritimes
  • The Foundry, or the Rust Belt: the central part of the the East Coast, from W Virginia to New York to Ohio, and including southern Ontario
  • Quebec, marked by the traditional provincial boundary but spreading a little eastward into Labrador
  • Dixie, or the Old South, down to south Florida
  • The Islands, comprised of south Florida, and the offshore islands, all the way to Venezuela
  • MexAmerica, essentially Texas to southern California and the old Spanish settlements and all of Mexico
  • Ecotopia, (home sweet home), the West Coast from Point Conception to Juneau
  • The Breadbasket, meaning the grain-producing midwest of the US and Canada
  • The Empty Quarter, the vast open spaces of the West, from the 100th meridian to the coastal mountain boundary with Ecotopia and north to Alaska, Canada’s Northwest and Yukon Territories, valued by residents for its mineral and oil wealth, and by non-residents for its unspoiled beauty.

I’ve lived in three four of the “nations” as it turns out: the Foundry, the Islands, Dixie and now Ecotopia. I found the summaries and descriptions of places I knew to be accurate, even 20 years on, and I assume the others are similarly close. In fact, in an article that came out in the wake of the book (linked below), the author says he was too conservative in his predictions of what the census’s results would bring.

I recommend giving this a look to understand why the regions act and vote the way they do and to see if you’re in the right one. I belong either here or New England, but Ecotopia suits me just fine. I’ll take my two seasons of breathtaking summers and light rain to the extremes of the east.

NB: here’s a link to an article that sums up the book’s premise with a Q&A section.