[wmii] Bug: Strings passed to libixp functions are modified

From: Stefan Tibus <sjti_AT_gmx.net>
Date: Thu, 12 Oct 2006 15:25:42 +0200

Hello there,

I'm trying to write a wmiirc for my wmii-4 in C to
make it faster (using wmiir as starting point).
However I noticed that functions within libixp,
e.g. ixp_client_dial, ixp_client_walk, modify the
the original strings passed to them. As far as
I've seen, this happens during tokenization of the
arguments (address for ixp_client_dial and filepath
for ixp_client_walk). Instead of copying the original
string and modifying the copy, the delimiter character
is replaced with \0 within the original string. This
has the very annoying side effect that one can't use
the same string variable twice. I don't consider this
good programming practice and would prefer to see this
fixed instead of me having to work around this
annoyance. BTW this problem even shows up in wmiir
itself (at least in wmii-4 hg from 2006-08-26):
Doing a
    wmiir remove lbar/bla
results in
    wmiir: cannot remove file 'lbar'
as the variable file in xremove contains
lbar \0 bla \0 instead of lbar/bla \0 after the
call to ixp_client_remove.

Note: man strtok says:
BUGS
       Avoid using these functions. If you do use them, note that:
              These functions modify their first argument.
              These functions cannot be used on constant strings.
              The identity of the delimiting character is lost.
and man strsep:
BUGS
       This function suffers from the same problems as strtok(). In particular, it modifies the original string. Avoid it.

Thus I consider libixp's behaviour a bug as well and
hope it's not too much work for it's developers to
fix this.

Regards,
Stefan

-- 
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl
Received on Thu Oct 12 2006 - 15:26:12 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:15:14 UTC