1

Try this on Mac OS X (don't worry, it won't crash your computer, it just spins):

printf "\314" | od -c

It seems that character 0314 somehow tricks od in its default Unicode mode (!) to look for further input, but there is none. I browsed the source a bit: http://www.opensource.apple.com/source/shell_cmds/shell_cmds-175/hexdump/conv.c

It seems like the bug is where it does goto retry; but I'm not sure. My question is: is this really where the bug is, and how would you fix it?


For bonus points, here's a command that outright crashes, due to another bug reported on the Free BSD bugs mailing list in 2006:

printf "\314\217" | od -c

This is still not fixed in Mac OS X, and apparently not in FreeBSD either, but at least it isn't an infinite loop! This one really makes me wonder, because it's not just these two characters which cause it--you can run od -c on a wide variety of large binary files and watch it crash. Do people really not use od much since 2006?

John Zwinck
  • 239,568
  • 38
  • 324
  • 436

0 Answers0