I thinks this qualifies for the daily wtf…
The encrypted hard drive project I was working on last quarter for my ECE 347 class is continuing into this quarter, as the other group member and I ran into some last minute issues with the hard drive (turned out to be a loose SATA cable) which prevented us from finishing the code. We were running into a huge number of bugs with my groupmate’s code, and when the hard drive disappeared from the system we called it a night. The other group member, who shall remain nameless, left Northwestern this quarter (no, it wasn’t Kurt ;)), and so I’m continuing the project on my own. As such, it was necessary for me to start modifying his portion of the code written for the project.
It is far and away the worse code I have ever seen. Every couple of lines, I find what seems to be a snippet of code specifically designed to win the “daily wtf of the year award.” After reading through the first page or two of some of his code, I decided to rewrite everything from scratch. I’m usually the type to try to keep as much code as possible, so I’m valiantly trying to incorporate as much of his code as possible, but there’s not anything salvageable in this mess.
The guy who wrote the code I’m rewriting was an interesting fellow. He certainly seemed bright. My suspicion that he wasn’t the sharpest knife in the drawer began after I pointed him towards a couple of papers to read for a (unrelated to the hard drive encryption project) mixed-mode placement algorithm we were working on. After a couple of days, he approached me and said he had spent “hours reading them” and that he knew enough to be comfortable starting to develop an algorithm. At this point, I was very impressed. I had read the papers quite a few times, and still didn’t quite know which methods I wanted to incorporate into our algorithm. I started into a technical discussion of my initial ideas, and he seemed to listen to and understand what I was saying. I was hoping that he would be able to provide some feedback on my ideas, indicate any obvious errors I was making, and maybe put forward some of his ideas. No such luck. His responses to my questions for feedback were limited to “That sounds good…”, “Should be fine…”, and “Yeah, just do that…” No problem, I thought, he’s just a bit timid, and doesn’t want to completely smash my silly ideas. I decided to get him to be a little more forthcoming by asking him to give me a quick rundown of what impressions he got from the different papers.
Utter. Disaster.
Although he had “read the papers for hours”, not only did he not understand the content of the papers, he did not understand the mixed-mode placement problem itself. As we had been working on this project for weeks, I was more than slightly dismayed. How could he have felt okay working on the project without understanding the problem we were trying to solve? Eventually, I ended up sitting down with him and developing an algorithm (a quite decent one too, I might add). At each step, I explained what I was doing, and asked for any feedback, criticism, or other ideas. All I got was blank stares. I did the writeup on the final algorithm, and sent it to him with an explanation of areas I’d like expanded on, in a last ditch effort to get him to contribute something. He replaced a few instances of the phrase “high quality solution” with “rather good answer”, added a diagram (an incorrect one), and sent it in. Although he sent in what was essentially a partially incorrect version of my first draft (without consulting me), we received an A on the project, which was a pleasant surprise. Despite the good grade, his complete lack of participation (in fact, his harmful participation) caused me to worry about his performance on his part of the encrypted hard drive project, with good reason as it turned out.
I wish I could post all of the code from the project here, but it would be an absolute chore to read. He seems to have an uncanny knack for introducing complexity where an obvious, concise solution exists. One of the simpler examples (there are much, much worse examples, but they are far too long to post here) of this is in his function to check whether the usb key is inserted or not.
He wrote the following:
checkusbkeyin = "sh usbtest.sh"
line1 = int(0)
while line1 != int(1):
# wait one second before trying again
# don't even think of taking this out to gain speed; benchmarking it without makes it up to 1 second faster but adds constant requests
time.sleep(1)
if line1 != int(1):
# Puts "1" in the file /mnt/usbkeyin if usbkey inserted and "0" if not
os.system(checkusbkeyin)
f = open("/mnt/usbkeyin")
line1 = int(f.readline())
f.close()
Which calls this shell script to generate the file queried by the python script:
if ! mount /mnt/usbdisk 2>/dev/null; then
echo "0" > /mnt/usbkeyin
else
echo "1" > /mnt/usbkeyin
fi
Here was my replacement:
mountkey = "mount /mnt/usbdisk"
# Now wait for key insertion
keyin = False
while keyin != True:
# Check for key
if os.system(mountkey) == 0:
keyin = True
# Don't want constant mount requests
time.sleep(0.1)
One of the first frightening sections I came across was his “unique” method of generating text output. Using Python like this should be a criminal offense. This guy really, really likes copy and paste coding:
Pregenerated output (Why? Who knows? There were 30 lines of this):
password00char = "/bin/lcd 2 ''"
password01char = "/bin/lcd 2 '*'"
password02char = "/bin/lcd 2 '**'"
password03char = "/bin/lcd 2 '***'"
password04char = "/bin/lcd 2 '****'"
password05char = "/bin/lcd 2 '*****'"
password06char = "/bin/lcd 2 '******'"
...continues...
The actual display output:
# do the star display
dispstar = keycounter % 15
if dispstar == 0 and keycounter > 0:
os.system(cpassword01char)
elif dispstar == 0:
os.system(password00char)
elif dispstar == 1 and keycounter > 1:
os.system(cpassword02char)
elif dispstar == 1:
os.system(password01char)
elif dispstar == 2 and keycounter > 2:
os.system(cpassword03char)
elif dispstar == 2:
os.system(password02char)
elif dispstar == 3 and keycounter > 3:
os.system(cpassword04char)
elif dispstar == 3:
os.system(password03char)
elif dispstar == 4 and keycounter > 4:
os.system(cpassword05char)
elif dispstar == 4:
os.system(password04char)
elif dispstar == 5 and keycounter > 5:
os.system(cpassword06char)
elif dispstar == 5:
os.system(password05char)
elif dispstar == 6 and keycounter > 6:
os.system(cpassword07char)
elif dispstar == 6:
...continues...
His ability to mangle code extends beyond Python however. I checked some of the C code he wrote, and was appalled at some of the errors I found. Again, there are far too many to post here, but here’s a very simple example:
char tty[9];
strcpy(tty, "/dev/ttyS0");
I can only assume he doesn’t understand C’s null termination of strings, and also doesn’t understand that, while arrays do start from 0, allocating an array of size 9 does exactly that, ie: indices 0 through 8 in the array are valid. He’s putting 11 characters into an array which can fit 9. Nearly every line of his code has bugs like this. I’m petrified that I’ll see his name as a contributor for an open source project.
In addition to this, the actual authentication method he used for the usb key doesn’t actually check the the usb key at all. Since he decided to store the keyfile on the hard drive itself, you can insert any old usb key and it will work just fine. His menu code is structured such that the smallest bug in any subsystem of the entire device will cause a complete meltdown. In fact, when we were about to present the rather nifty menu system we managed to complete to our professor when he insisted on making “a few quick changes.” I advised him to not touch anything, but he went ahead and “fixed up” some of the code. By the time our professor showed up, nothing was working. He just shrugged, and told our professor to write him a check for the money he spent in parts (including the $80 for the LCD screen he shorted out, and its replacement which he nearly destroyed before I had a chance to mount it).
He has since ceased responding to email, which could have been a problem, as he set a BIOS password for some reason. Luckily, clearing the CMOS also cleared the password, allowing me access to the BIOS setup. I worked on the new code a bit today, and it’s coming together quite nicely. It’s functional, fast, and a bug in one section won’t cause any problems outside of it’s own little area of functionality. I plan on posting the code, and pictures of the actual encrypted hard drive (taken with my new camera), when it’s completed.
The usual random notes:
- I’m taking a “human computer interaction” course this quarter, which I’m looking forward to. Since it’s likely I’ll be doing some multimedia GUI development, it’ll be good to have some UI design experience.
- I’m also taking a VHDL class, and the professor is great. Should be a lot of fun, and quite useful.
- Suse 10.0 is still running strong, with 61 days of uptime now, and 30638 remote SSH attempts.
- Why the sudden departure from NU, Kurt? Any specific reason for leaving?
- I am now running Wordpress 2.0. Amazingly easy upgrade. Took about 10 minutes.
- The weather here is awful.

If it’s CS330, I took that HCI class last winter quarter. If it’s run the same way as last year (meaning every year), the actual design-aspect is super light-weight. The class is discussion-type (where articles are assigned to be read, then they’re discussed in class–I think there’s a more technical term for this type of class), then every few weeks, groups present their designs or re-designs of an interface for a typical, future device. For example, one of our assignments was making an interface for a cell phone that could store 10GBs of pictures. The challenges were more fun than enlightening. There’s something to be said for “fun,” but there’s also something to be said “substantial.” The readings are fairly interesting, but you won’t apply much of their content to the projects unless you really try, and you’re a brown-noser. Not to say the class wasn’t fine, just that it, unlike both a lot and very few other classes, is what you make of it. If you want to make some glorious UI for a useful program (x264 needs an interface and stat!), you can, as you choose your final project, but be wary of ending up in a bad (randomly-assigned) group. In short: good class, but it’s what you make of it. And make sure that you don’t end up with anyone from Fiji in your group; the whole “pot-smoker” fraternity stereotype is very true.
Dan said this on January 5th, 2006 at 12:31 am
I realize it’s not going to be a challenging class. I’m pretty much finished with all the classes I have to take though, and I don’t really want to graduate early. I’m hoping it’ll be fairly easy, so I have time to perfect my ECE 347 project, but still interesting. I also need some UI design skills. And yes, I’ve worked with someone from Fiji before. I won’t make the same mistake twice.
Andrew said this on January 5th, 2006 at 1:04 am
Whoa, you got me. I wasn’t expecting you to figure out I was gone for quite a while, even with the awkward phone call I gave you just before leaving. One of the reasons I’m on a sabbatical is so that I can take some time and figure out what I want to do - college has become a real chore, and I was barely staying afloat with no real goals. So I’m going to save my time and my parents’ money, and figure out what it is I want to get out of higher education. When I’m ready, I’ll come back (probably at the beginning of the 2006-2007 school year).
I’m looking forward to upgrading to Wordpress 2.0, particularly because in the backend they’ve replaced all inline Mysql statements with function calls to allow it to become database-independent. I’m rooting for a port to Postgresql, at which point I’ll convert my Gallery2 installation as well.
Kurt McKee said this on January 9th, 2006 at 12:02 am
I had the unfortunate experience of spending some time in the same class as your nameless group member. I found him to be slightly different than discribed. For example, he did not feel the need to not talk, but did so in plethera. Fortunately he didn’t say anything worth listening to, so I felt free to ignore him.
It turns out he also had a number of odd quirks. First, he was a vegan (nothing out of the ordinary), but also refused to drink anything other than water (which struck me as odd). Second, he complained continuously about the service provided in the general Northwestern Computer Labs. When I questioned on him why he didn’t just use his own computer it led to the third thing: he refused to connect to any network. Later of course, this was qualified as certain networks (which for all intensive purposes included all he might reach). On top of all this, he had some weird preoccupation with bit vectors, which I’ll never understand.
The list goes on of course, and I was shown a bit of his code for a different class, which included if statements on variables that were just assigned, and a failure of understanding switch/case.
Jim said this on January 18th, 2006 at 6:52 pm
I ran into all the problems you mentioned with him as well. The “I won’t use NU network services” thing was a huge hindrance. Eventually I persuaded him to connect our development computer to his dorm ethernet jack, but he insisted on spoofing a MAC address and using a static IP, which meant that it was almost always down. You’re right about him not knowing how to stop talking. I once mentioned I was buying a new microwave, and he managed to talk my ear off for an hour about the different kinds of microwaves on the market. Thankfully, I don’t have to deal with him any more, and the new code is working wonderfully. The new menu system takes ~15 lines of code (thanks to lambda), whereas his took ~350 lines.
Andrew said this on January 19th, 2006 at 1:37 am
Yo Andy, if you’re graduating this quarter, we gotta get together sometime for a meal and a chat.
Jeff said this on February 24th, 2006 at 7:25 pm
Nope, not graduating this quarter. Just taking a nice easy schedule next quarter.
Andrew said this on February 25th, 2006 at 2:53 pm
How ’bout you update this so I’m not stuck rereading the same WTF stuff over and over and over again? Hmph.
Sarah said this on March 7th, 2006 at 10:01 am
Yes, I realize I’ve neglected my site a bit recently. I’ll post soon. Really.
Andrew said this on March 8th, 2006 at 4:08 pm
Ping. Now post a pong!
NOTE: “ping” and “pong” are not some new blogging meme, like the “best blonde joke in the world” or some such nonsense. I personally made it up just now to remind Andy to post his further exploits. Gimmick infringement will be tolerated.
Kurt McKee said this on March 19th, 2006 at 2:56 am