Bug#597127: xboard: Bad path results in segmentation fault

Rafael Cunha de Almeida rafael at kontesti.me
Thu Sep 16 20:20:56 UTC 2010

Package: xboard
Version: 4.2.7-7.1
Severity: normal
Tags: patch

Yesterday I was editing a game which I was reading about in a book.
After I finished placing all the moves in the game I tried the "save
game" option. I wanted to save it to ~/chess/game1.pgn, but I mistakenly
typed ~ /chess/game1.pgn (note the space). Xboard didn't take it very
well, it segfaulted on me :-(. Very annoying.

Today I decided to take a look at xboard's code. I don't know what this
logic is all about, but I think it might make paths with spaces buggy:
	p = strrchr(buf, ' ');
	if (p == NULL) {
	    index = 0;
	} else {
	    *p++ = NULLCHAR;
	    index = atoi(p);
However, I didn't touch it. Who knows what mystery it might hide, right?

The patch I written changes another function, ExpandPathName, this one I
think I got completely figured out. What I did was to make it expand ~
if the next character is white space. This way we avoid the segmentation
fault altogether. It gives the user a nice error. I assume there are not
many nice ways to interpret a path like:

	~ /chess/game1.pgn

Perhaps ~/ /chess/game1.pgn? I'm not sure anyone has their system layout
like that. So I think an error -- which my patch accomplishes -- is good

I wrote the patch for xboard 4.2.7, hence the version, but it does work
in all the versions I've tested (4.4.3 and 4.5~git20100118-1). By the
way, the bug applies to all those versions. Finally, I'm not very good
with reportbug program, so I might take a few tries before I send the
patch (hopefully not).

-- System Information:
Debian Release: 5.0.5
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-x86_64-linode11 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xboard.patch
Type: text/x-diff
Size: 400 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-games-devel/attachments/20100916/572bcba1/attachment.patch>

More information about the Pkg-games-devel mailing list