signed vs unsigned char issue with silc-server config parser
Brad <brad-BUbV6I797GxWk0Htik3J/[email protected]> Thu, 15 Jan 2009 10:36:00 -0500
| Newsgroups | gmane.network.silc.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============1854223630==
Content-Type: text/plain; charset=unknown-8bit
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
The silc-server config parser has an issue with signed vs unsigned char
usage in the code. This causes the config parser to break on PowerPC
and ARM systems.
$ ./silcd
Error while parsing config file: Unknown option.
file /home/brad/etc/silcd/silcalgs.conf line 121: =FF
There are only 120 lines in the file.
Here are some patches which have been in the OpenBSD silc-server port
for ages now. I don't expect them to be the best possible patches but
I'll provide them as a reference.
--- lib/silcutil/silcconfig.c.orig Sun Sep 9 11:04:15 2007
+++ lib/silcutil/silcconfig.c Fri Feb 29 23:46:17 2008
@@ -95,7 +95,7 @@ char *silc_config_strerror(int errnum)
/* Points the first non-space character */
static void my_trim_spaces(SilcConfigFile *file)
{
- register char *r =3D file->p;
+ signed char *r =3D file->p;
while ((*r !=3D '\0' && *r !=3D EOF) && isspace((int)*r))
if (*r++ =3D=3D '\n') file->line++;
file->p =3D r;
@@ -104,7 +104,7 @@ static void my_trim_spaces(SilcConfigFile *file)
/* Skips the current line until newline (lf or cr) */
static void my_skip_line(SilcConfigFile *file)
{
- register char *r =3D file->p;
+ signed char *r =3D file->p;
while ((*r !=3D '\0' && *r !=3D EOF) && (*r !=3D '\n') && (*r !=3D '\r=
')) r++;
file->p =3D ((*r !=3D '\0' && *r !=3D EOF) ? r + 1 : r);
file->line++;
@@ -336,9 +336,9 @@ SilcUInt32 silc_config_get_line(SilcConfigFile *file)
=20
char *silc_config_read_line(SilcConfigFile *file, SilcUInt32 line)
{
- register char *p;
+ signed char *p;
int len;
- char *ret =3D NULL, *endbuf;
+ signed char *ret =3D NULL, *endbuf;
=20
if (!file || (line <=3D 0))
return NULL;
@@ -461,7 +461,7 @@ SilcBool silc_config_register_table(SilcConfigEntity =
e
static int silc_config_main_internal(SilcConfigEntity ent)
{
SilcConfigFile *file =3D ent->file;
- char **p =3D &file->p;
+ signed char **p =3D &file->p;
=20
/* loop throught statements */
while (1) {
--- lib/silcutil/silcutil.c.orig Sat Nov 19 17:26:20 2005
+++ lib/silcutil/silcutil.c Sun Apr 1 22:42:28 2007
@@ -45,7 +45,7 @@ int silc_gets(char *dest, int destlen, const char *src
=20
dest[i] =3D src[start];
=20
- if (dest[i] =3D=3D EOF)
+ if ((signed char)dest[i] =3D=3D EOF)
return EOF;
=20
if (dest[i] =3D=3D '\n')
--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--===============1854223630==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________________________________
Info: https://lists.silcnet.org/mailman/listinfo/silc-announce
Archive: https://lists.silcnet.org/pipermail/silc-announce
FAQ: http://silcnet.org/support/faq/
--===============1854223630==--