Ethereal-dev: [Ethereal-dev] Questions about a few code fragments

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Brad Hards <bhards@xxxxxxxxxxxxxx>
Date: Thu, 13 Nov 2003 11:39:57 +1100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm looking over Ethereal, and I've found a few bits that look more-or-less 
wrong. If people have time, can I get some feedback. If they are confirmed as 
problems, I can start with the patching.

A typical example is found In disabled_protos.c (around line 286), where there 
is code that looks like:

  /* Write to "XXX.new", and rename if that succeeds.
     That means we don't trash the file if we fail to write it out
     completely. */
  ff_path_new = (gchar *) g_malloc(strlen(ff_path) + 5);
  sprintf(ff_path_new, "%s.new", ff_path);

That is in trouble if the g_malloc fails (which I assume it can - glib 
documentation isn't that great). This construct is used in a few places.

Also, is the output of sprintf assured to be only the size of the formatted 
input strings? I'm thinking about platforms that use unicode variations...

Brad

- -- 
http://lca2004.linux.org.au - I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/stLhGwwszQ/PZzgRAlTAAKCFdaUJaq5aBAyTk7Edxs/f5LRtGQCZAUWz
BQsmMJXGC5rPbHJ+V3CHYvo=
=lgyM
-----END PGP SIGNATURE-----