[Help-gnutls] Re: Really I can not understand nothing of SSL... For the moment to avoid confusion...

Fran e_agf at yahoo.es
Sat Aug 13 13:57:28 CEST 2005


> > I suggest this modifications for certtoll-cfg.c function read_int(), for
> > the moment:
> > Something like this:
> > Line 32:
> >> #include <limits.h>
> > Line 224:
> >>  if (atoll (input) > INT_MAX) /*Could be other condition*/
> >>     {
> >>       fprintf (stderr, "Sorry certtool still  not support numbers larger that: %u\n", INT_MAX);
> >>       return 0;
> >>     };
> 
> atoll isn't available on C89 platforms..

Right, atoi (obsolete) , and atoll (C99 and obsolete),but "something
like" this is not "this".
 What about this?
> 
> #include <limits.h> 
> #include <errno.h> 
> 
> int
> read_int (const char *input_str)
> {
>   char input[128];
> 
>   unsigned char buf[512]; /* I don' t known max size of errors returned */
>   int err;
>   unsigned char cond = 1;
> 
>   while (cond)
>     {
>       fputs (input_str, stderr);
>       fgets (input, sizeof (input), stdin);
> 
>       cond = (((err = strtol (input, NULL, 10)) >= INT_MAX) || (err == EINVAL) || (err == ERANGE) || (strlen (input) == 1) || (err == 0)); 
> /*last value not permited INT_MAX -1, zero I think that should not be used, ERANGE not used */
>       if (cond)
>         {
>           if ((err == EINVAL) || (err == ERANGE))
>             {
>               strerror_r (err, buf, sizeof (buf)); /* It's  C89 ? */
>               fprintf (stderr, "Error : Function fail to get int value: %s", buf);
>             }
>           else
>             {
>               fprintf (stderr, "Error : Number is too big for certtool, zero or invalid\n");
>             };
> /*      return 0;*/
>         }
>       else
>         {
>           fprintf (stderr, "Value set to: %u", err);
>         };
>     };
> 
>   return atoi (input);
> }

I think that certool should not caught values that can not process.
That's all.

Regards,





More information about the Gnutls-help mailing list