[Uim] reliability fix: uim-fep.c

Iwata iwata at quasiquote.org
Thu Mar 29 20:10:43 EEST 2007


Hi,

"Etsushi Kato" <ek.kato at gmail.com> writes:

> Thanks for your patch.  I haven't checked you patch in detailed yet, I
> noticed one missing thing about asprintf replacement.  IIRC, some
> version of SUN OS (Solaris?) have broken vsnprintf, so if you use
> bsd-asprintf.c you need to use bsd-snprintf.c as well and
> corresponding check with configure.ac.  Could you revise the patch to
> use that?

what hypocrite os is.
Right, I wrote new patch, copied configure.ac entry from openssh-portable,
and zapped same functions in xim/util.cpp.

 http://quasiquote.org/patches/uim-fepp1.diff.gz

I cannot test under BROKEN_SNPRINTFed environment, sorry.


BTW, I append strtonum(3) to this patch.
I suggest replacing atoi(3) and strtol*(3) to strtonum.

atoi is poor parser and no error checking such as overflow.

strto* is better than atoi, but, in uim, lack correct handling.
For example (from 'man strtol' in OpenBSD),

  char *ep;
  int ival;
  long lval;

  errno = 0;
  lval = strtol(buf, &ep, 10);
  if (buf[0] == '\0' || *ep != '\0')
    goto not_a_number;
  if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) ||
      (lval > INT_MAX || lval < INT_MIN))
         goto out_of_range;
  ival = lval;

strtonum is easy to use (but ugly) and works correctly. such as

  int iterations;
  const char *errstr;

  iterations = strtonum(optarg, 1, 64, &errstr);
  if (errstr)
    errx(1, "number of iterations is %s: %s", errstr, optarg);

Please read CAVEATS.

  http://www.openbsd.org/cgi-bin/man.cgi?query=atoi&sektion=0&format=html#end





More information about the uim mailing list