+Sat Jan 11 18:16:29 CET 2003 Giovanni Giacobbi <giovanni@giacobbi.net>
+
+ * Fixed server crash with double Primary block in config file.
+
+ Fixed also various memory leaks around the config file
+ parser. Affected files lib/silcutil/silcconfig.c,
+ silcd/serverconfig.c.
+
+ * Changed my nickname (Johnny Mnemonic) to my real name, this
+ means that bugs introduced by him were actually introduced
+ by me!
+
Tue Jan 7 21:58:53 CET 2003 Jochen Eisinger <c0ffee@penguin-breeder.org>
* Don't display "foo appears as foo\nYou're now known as foo"
S: 53850 Lappeenranta
S: Finland
-N: Johnny Mnemonic
+N: Giovanni Giacobbi
+E: giovanni@giacobbi.net
E: johnny@themnemonic.org
-W: http://www.themnemonic.org/
-P: 1024D/34E2AB40 9AC6 1460 A5D0 4DB7 70D0 5DA5 C17F 50CD 34E2 AB40
+P: 1024D/B2D79FC1 6247 640C 1C90 1EE4 D800 E4E2 2D58 3DF1 B2D7 9FC1
+D: silcconfig, silclog, various patches around
D: RPM packages
-D: silclog, misc bugfixes
S: 35100 Padova
S: Italy
serverconfig.c
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
Copyright (C) 1997 - 2002 Pekka Riikonen
SILC_SERVER_CONFIG_SECTION_INIT(SilcServerConfigServerInfoInterface);
SilcServerConfigServerInfo *server_info = config->server_info;
- /* if there isn't the struct alloc it */
+ SERVER_CONFIG_DEBUG(("Received SERVERINFO type=%d name=\"%s\" (val=%x)",
+ type, name, context));
+
+ /* if there isn't the main struct alloc it */
if (!server_info)
config->server_info = server_info = (SilcServerConfigServerInfo *)
silc_calloc(1, sizeof(*server_info));
if (type == SILC_CONFIG_ARG_BLOCK) {
if (!strcmp(name, "primary")) {
+ if (server_info->primary) {
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Double primary specification."));
+ got_errno = SILC_CONFIG_EPRINTLINE;
+ goto got_err;
+ }
CONFIG_IS_DOUBLE(server_info->primary);
- if (!tmp)
- return SILC_CONFIG_OK;
+
+ /* now check the temporary struct, don't accept empty block and
+ make sure all fields are there */
+ if (!tmp || !tmp->server_ip || !tmp->port) {
+ got_errno = SILC_CONFIG_EMISSFIELDS;
+ goto got_err;
+ }
server_info->primary = tmp;
config->tmp = NULL;
return SILC_CONFIG_OK;
} else if (!strcmp(name, "secondary")) {
if (!tmp)
return SILC_CONFIG_OK;
+ if (!tmp || !tmp->server_ip || !tmp->port) {
+ got_errno = SILC_CONFIG_EMISSFIELDS;
+ goto got_err;
+ }
SILC_SERVER_CONFIG_LIST_APPENDTMP(server_info->secondary);
config->tmp = NULL;
return SILC_CONFIG_OK;
return SILC_CONFIG_OK;
got_err:
- silc_free(tmp);
- silc_free(config->tmp);
- config->tmp = NULL;
+ /* here we need to check if tmp exists because this function handles
+ * misc data (multiple fields and single-only fields) */
+ if (tmp) {
+ silc_free(tmp->server_ip);
+ silc_free(tmp);
+ config->tmp = NULL;
+ }
return got_errno;
}
}
}
silc_server_config_destroy(config_new);
+ silc_config_close(file);
return NULL;
}
serverconfig.h
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
Copyright (C) 1997 - 2002 Pekka Riikonen
SILC is designed and written by Pekka Riikonen <priikone@iki.fi> and rest
of the SILC Project.
-Configuration file format and parser is by Johnny Mnemonic.
+Configuration file format and parser is by Giovanni Giacobbi
+<giovanni@giacobbi.net>.
This manpage was written by Mika 'Bostik' Boström <bostik@lut.fi>
silcconfig.c
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
- Copyright (C) 1997 - 2002 Pekka Riikonen
+ Copyright (C) 2002 - 2003 Giovanni Giacobbi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
return NULL;
}
-/* ... */
+/* Converts a string in the type specified. returns a dynamically
+ * allocated pointer. */
static void *silc_config_marshall(SilcConfigType type, const char *val)
{
void *pt;
}
else {
void *pt;
- int ret;
+ int ret = 0; /* very important in case of no cb */
if (*(*p)++ != '=')
return SILC_CONFIG_EEXPECTEDEQUAL;
pt = silc_config_marshall(thisopt->type, buf);
if (!pt)
return SILC_CONFIG_EINVALIDTEXT;
- if (thisopt->cb) {
+ if (thisopt->cb)
ret = thisopt->cb(thisopt->type, thisopt->name, file->line,
pt, thisopt->context);
- if (ret) {
- SILC_CONFIG_DEBUG(("Callback refused the value [ret=%d]", ret));
- return ret;
- }
- }
+
+ /* since we have to free "pt" both on failure and on success, we
+ assume that ret == 0 if we didn't actually call any cb. */
silc_free(pt);
+ if (ret) {
+ SILC_CONFIG_DEBUG(("Callback refused the value [ret=%d]", ret));
+ return ret;
+ }
}
continue;
silcconfig.h
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
- Copyright (C) 1997 - 2002 Pekka Riikonen
+ Copyright (C) 2002 - 2003 Giovanni Giacobbi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
silclog.c
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
Copyright (C) 1997 - 2002 Pekka Riikonen
silclog.h
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
Copyright (C) 1997 - 2002 Pekka Riikonen
#
# stripspaces.tcl - strip trailing spaces from source files
#
-# Author: Johnny Mnemonic <johnny@themnemonic.org>
+# Author: Giovanni Giacobbi <giovanni@giacobbi.net>
#
-# Copyright (C) 2002 Johnny Mnemonic
+# Copyright (C) 2002 - 2003 Giovanni Giacobbi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by