SILC_SERVER_LOG_ERROR(("Error while parsing config file: %s.",
silc_config_strerror(ret)));
linebuf = silc_config_read_line(file, line);
- SILC_SERVER_LOG_ERROR((" file %s line %lu: %s\n", filename,
- line, linebuf));
- silc_free(linebuf);
+ if (linebuf) {
+ SILC_SERVER_LOG_ERROR((" file %s line %lu: %s\n", filename,
+ line, linebuf));
+ silc_free(linebuf);
+ }
}
silc_server_config_destroy(config_new);
return NULL;
len = 0;
for (i = 0; i < argc; i++)
- len += 3 + argv_lens[i];
+ len += 3 + (SilcUInt16)argv_lens[i];
buffer = silc_buffer_alloc_size(len);
if (!buffer)
silc_buffer_format(buffer,
SILC_STR_UI_SHORT(argv_lens[i]),
SILC_STR_UI_CHAR(argv_types[i]),
- SILC_STR_UI_XNSTRING(argv[i], argv_lens[i]),
+ SILC_STR_UI_XNSTRING(argv[i], (SilcUInt16)argv_lens[i]),
SILC_STR_END);
- silc_buffer_pull(buffer, 3 + argv_lens[i]);
+ silc_buffer_pull(buffer, 3 + (SilcUInt16)argv_lens[i]);
}
silc_buffer_push(buffer, len);
SilcUInt32 arg_type)
{
SilcBuffer buffer = args;
- int len;
+ SilcUInt32 len;
- len = 3 + arg_len;
+ len = 3 + (SilcUInt16)arg_len;
buffer = silc_buffer_realloc(buffer,
(buffer ? buffer->truelen + len : len));
if (!buffer)
silc_buffer_format(buffer,
SILC_STR_UI_SHORT(arg_len),
SILC_STR_UI_CHAR(arg_type),
- SILC_STR_UI_XNSTRING(arg, arg_len),
+ SILC_STR_UI_XNSTRING(arg, (SilcUInt16)arg_len),
SILC_STR_END);
silc_buffer_push(buffer, buffer->data - buffer->head);
{
SilcBuffer tmpbuf = NULL;
unsigned char tmp[4], *str = NULL, *ret;
- int len;
+ SilcUInt32 len;
/* Encode according to attribute type */
if (flags & SILC_ATTRIBUTE_FLAG_VALID) {
case SILC_ATTRIBUTE_SERVICE:
{
SilcAttributeObjService *service = object;
- int len2;
+ SilcUInt32 len2;
if (object_size != sizeof(*service))
return NULL;
len = strlen(service->address);
case SILC_ATTRIBUTE_GEOLOCATION:
{
SilcAttributeObjGeo *geo = object;
- int len1, len2, len3, len4;
+ SilcUInt32 len1, len2, len3, len4;
if (object_size != sizeof(*geo))
return NULL;
len1 = (geo->longitude ? strlen(geo->longitude) : 0);
case SILC_ATTRIBUTE_DEVICE_INFO:
{
SilcAttributeObjDevice *dev = object;
- int len1, len2, len3, len4;
+ SilcUInt32 len1, len2, len3, len4;
if (object_size != sizeof(*dev))
return NULL;
len1 = (dev->manufacturer ? strlen(dev->manufacturer) : 0);
SilcBufferStruct buffer;
SilcDList list;
SilcAttributePayload newp;
- int len, ret;
+ SilcUInt32 len;
+ int ret;
SILC_LOG_DEBUG(("Parsing Attribute Payload list"));
SilcUInt32 data_len)
{
SilcBuffer buffer = attrs;
- int len;
+ SilcUInt32 len;
- len = 4 + data_len;
+ len = 4 + (SilcUInt16)data_len;
buffer = silc_buffer_realloc(buffer,
(buffer ? buffer->truelen + len : len));
if (!buffer)
SILC_STR_UI_CHAR(attribute),
SILC_STR_UI_CHAR(flags),
SILC_STR_UI_SHORT((SilcUInt16)data_len),
- SILC_STR_UI_XNSTRING(data, data_len),
+ SILC_STR_UI_XNSTRING(data, (SilcUInt16)data_len),
SILC_STR_END);
silc_buffer_push(buffer, buffer->data - buffer->head);
/*
- silcchannel.c
+ silcchannel.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
-/* Channel Payload, Channel Message Payload and Channel Key Payload
- implementations. */
+/* Channel Payload and Channel Key Payload implementations. */
/* $Id$ */
#include "silcincludes.h"
SilcBufferStruct buffer;
SilcDList list;
SilcChannelPayload newp;
- int len, ret;
+ SilcUInt32 len;
+ int ret;
SILC_LOG_DEBUG(("Parsing channel payload list"));
/*
- silccommand.c
+ silccommand.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
}
if (newp->cmd == 0) {
+ SILC_LOG_ERROR(("Incorrect command type in command payload"));
silc_free(newp);
return NULL;
}
if (argc) {
args = silc_argument_payload_encode(argc, argv, argv_lens, argv_types);
+ if (!args)
+ return NULL;
len = args->len;
}
if (payload->args) {
args = silc_argument_payload_encode_payload(payload->args);
- len = args->len;
+ if (args)
+ len = args->len;
argc = silc_argument_get_arg_num(payload->args);
}
static void silc_idcache_destructor(void *key, void *context,
void *user_context)
{
- silc_free(context);
+ SilcIDCacheEntry c = context;
+ if (c) {
+ memset(c, 'F', sizeof(*c));
+ silc_free(c);
+ }
}
/* Delete cache entry from cache. */
if (old->id)
ret = silc_hash_table_del(cache->id_table, old->id);
else
- silc_free(old);
+ silc_idcache_destructor(NULL, old, NULL);
return ret;
}
if (c->id)
ret = silc_hash_table_del_by_context(cache->id_table, c->id, c);
else
- silc_free(c);
+ silc_idcache_destructor(NULL, c, NULL);
return ret;
}
SilcIDCache cache = (SilcIDCache)user_context;
SilcUInt32 curtime = time(NULL);
SilcIDCacheEntry c = (SilcIDCacheEntry)context;
+ bool ret = FALSE;
if (!context)
return;
if (c->expire && c->expire < curtime) {
/* Remove the entry from the hash tables */
if (c->name)
- silc_hash_table_del_by_context(cache->name_table, c->name, c);
+ ret = silc_hash_table_del_by_context(cache->name_table, c->name, c);
if (c->context)
- silc_hash_table_del(cache->context_table, c->context);
+ ret = silc_hash_table_del(cache->context_table, c->context);
if (c->id)
- silc_hash_table_del_by_context_ext(cache->id_table, c->id, c,
- NULL, NULL, NULL, NULL,
- silc_idcache_destructor_dummy, NULL);
-
- /* Call the destructor */
- if (cache->destructor)
- cache->destructor(cache, c);
-
- /* Free the entry, it has been deleted from the hash tables */
- silc_free(c);
+ ret =
+ silc_hash_table_del_by_context_ext(cache->id_table, c->id, c,
+ NULL, NULL, NULL, NULL,
+ silc_idcache_destructor_dummy,
+ NULL);
+ if (ret == TRUE) {
+ /* Call the destructor */
+ if (cache->destructor)
+ cache->destructor(cache, c);
+
+ /* Free the entry, it has been deleted from the hash tables */
+ silc_idcache_destructor(NULL, c, NULL);
+ }
}
}
silc_hash_table_del_by_context_ext(cache->id_table, c->id, c,
NULL, NULL, NULL, NULL,
silc_idcache_destructor_dummy, NULL);
-
- /* Call the destructor */
- if (cache->destructor)
- cache->destructor(cache, c);
+ if (ret == TRUE) {
+ /* Call the destructor */
+ if (cache->destructor)
+ cache->destructor(cache, c);
- /* Free the entry, it has been deleted from the hash tables */
- silc_free(c);
+ /* Free the entry, it has been deleted from the hash tables */
+ silc_idcache_destructor(NULL, c, NULL);
+ }
return ret;
}
/*
- silcnotify.c
+ silcnotify.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2000 Pekka Riikonen
+ Copyright (C) 2000 - 2002 Pekka Riikonen
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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
unsigned char **argv;
SilcUInt32 *argv_lens = NULL, *argv_types = NULL;
unsigned char *x;
- SilcUInt32 x_len;
- int i, k = 0, len = 0;
+ SilcUInt32 x_len, len = 0;
+ int i, k = 0;
if (argc) {
argv = silc_calloc(argc, sizeof(unsigned char *));
SilcBuffer args)
{
SilcBuffer buffer;
- int len;
+ SilcUInt32 len;
len = 5 + (args ? args->len : 0);
buffer = silc_buffer_alloc_size(len);
const SilcBuffer assembled_packet)
{
unsigned char tmppad[SILC_PACKET_MAX_PADLEN];
- int block_len = cipher ? silc_cipher_get_block_len(cipher) : 0;
+ unsigned int block_len = cipher ? silc_cipher_get_block_len(cipher) : 0;
int i, ret;
SILC_LOG_DEBUG(("Assembling outgoing packet"));
SilcHmac hmac,
const SilcBuffer packet)
{
- int totlen;
+ SilcUInt32 totlen;
unsigned char *oldptr;
- int mac_len = hmac ? silc_hmac_len(hmac) : 0;
+ unsigned int mac_len = hmac ? silc_hmac_len(hmac) : 0;
if (!packet)
return FALSE;
void *parser_context)
{
SilcPacketParserContext *parse_ctx;
- int packetlen, paddedlen, mac_len = 0, ret, block_len;
+ SilcUInt16 packetlen;
+ SilcUInt32 paddedlen, mac_len = 0, block_len;
+ int ret;
bool cont = TRUE;
unsigned char tmp[SILC_PACKET_MIN_HEADER_LEN], *header;
unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
return FALSE;
parse_ctx->packet = silc_packet_context_alloc();
parse_ctx->packet->buffer = silc_buffer_alloc_size(paddedlen);
- parse_ctx->packet->type = header[3];
- parse_ctx->packet->padlen = header[4];
+ parse_ctx->packet->type = (SilcPacketType)header[3];
+ parse_ctx->packet->padlen = (SilcUInt8)header[4];
parse_ctx->packet->sequence = sequence++;
parse_ctx->sock = sock;
parse_ctx->context = parser_context;
/* Decrypt rest of the header plus padding */
if (cipher) {
SilcUInt16 len;
- int block_len = silc_cipher_get_block_len(cipher);
+ SilcUInt32 block_len = silc_cipher_get_block_len(cipher);
SILC_LOG_DEBUG(("Decrypting the header"));
#define SILC_PACKET_LENGTH(__packetdata, __ret_truelen, __ret_paddedlen) \
do { \
SILC_GET16_MSB((__ret_truelen), (__packetdata)); \
- (__ret_paddedlen) = (__ret_truelen) + (__packetdata)[4]; \
+ (__ret_paddedlen) = (__ret_truelen) + (SilcUInt8)(__packetdata)[4]; \
} while(0)
/***/
SILC_LOG_DEBUG(("Re-encoding was successful"));
+ SILC_LOG_DEBUG(("Checking number of arguments"));
+ SILC_LOG_DEBUG(("Number of arguments: %d (expecting %d)",
+ silc_argument_get_arg_num(payload), ARG_NUM + 1));
+ if (silc_argument_get_arg_num(payload) != ARG_NUM + 1)
+ goto out;
+
+
SILC_LOG_DEBUG(("Traversing the parsed arguments"));
i = 0;
a = silc_argument_get_first_arg(payload, &t, &l);
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 Pekka Riikonen
+ Copyright (C) 2001 - 2002 Pekka Riikonen
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
SilcBuffer silc_sftp_attr_encode(SilcSFTPAttributes attr)
{
SilcBuffer buffer;
- int i, ret, len = 4;
+ int i, ret;
+ SilcUInt32 len = 4;
if (attr->flags & SILC_SFTP_ATTR_SIZE)
len += 8;
}
}
- buffer = silc_buffer_alloc(len);
+ buffer = silc_buffer_alloc_size(len);
if (!buffer)
return NULL;
- silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer));
silc_buffer_format(buffer,
SILC_STR_UI_INT(attr->flags),
/*
- payload.c
+ payload.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2000 - 2001 Pekka Riikonen
+ Copyright (C) 2000 - 2002 Pekka Riikonen
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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
if (!payload)
return SILC_SKE_STATUS_ERROR;
- buf = silc_buffer_alloc(payload->len);
+ buf = silc_buffer_alloc_size(payload->len);
if (!buf)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
- silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
/* Encode the payload */
ret = silc_buffer_format(buf,
}
if (tmp != 0) {
- SILC_LOG_DEBUG(("Bad reserved field"));
SILC_LOG_ERROR(("Bad RESERVED field in KE Start Payload"));
status = SILC_SKE_STATUS_BAD_RESERVED_FIELD;
goto err;
/* Allocate channel payload buffer. The length of the buffer
is 4 + public key + 2 + x + 2 + signature. */
- buf = silc_buffer_alloc(4 + payload->pk_len + 2 + x_len +
- 2 + payload->sign_len);
+ buf = silc_buffer_alloc_size(4 + payload->pk_len + 2 + x_len +
+ 2 + payload->sign_len);
if (!buf)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
- silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
/* Encode the payload */
ret = silc_buffer_format(buf,
}
silc_free(ske->hash);
silc_free(ske->callbacks);
+
+ memset(ske, 'F', sizeof(*ske));
silc_free(ske);
}
}
/* Set random cookie */
rp->cookie = silc_calloc(SILC_SKE_COOKIE_LEN, sizeof(*rp->cookie));
for (i = 0; i < SILC_SKE_COOKIE_LEN; i++)
- rp->cookie[i] = silc_rng_get_byte(ske->rng);
+ rp->cookie[i] = silc_rng_get_byte_fast(ske->rng);
rp->cookie_len = SILC_SKE_COOKIE_LEN;
/* Put version */
/* XXX */
/* Get supported compression algorithms */
- rp->comp_alg_list = strdup("");
- rp->comp_alg_len = 0;
+ rp->comp_alg_list = strdup("none");
+ rp->comp_alg_len = strlen("none");
rp->len = 1 + 1 + 2 + SILC_SKE_COOKIE_LEN +
2 + rp->version_len +
payload->hmac_alg_list = strdup(rp->hmac_alg_list);
}
-#if 0
/* Get supported compression algorithms */
- cp = rp->hash_alg_list;
+ cp = rp->comp_alg_list;
if (cp && strchr(cp, ',')) {
while(cp) {
char *item;
item = silc_calloc(len + 1, sizeof(char));
memcpy(item, cp, len);
- SILC_LOG_DEBUG(("Proposed hash alg `%s'", item));
+ SILC_LOG_DEBUG(("Proposed Compression `%s'", item));
- if (silc_hash_is_supported(item) == TRUE) {
- SILC_LOG_DEBUG(("Found hash alg `%s'", item));
-
- payload->hash_alg_len = len;
- payload->hash_alg_list = item;
+#if 1
+ if (!strcmp(item, "none")) {
+ SILC_LOG_DEBUG(("Found Compression `%s'", item));
+ payload->comp_alg_len = len;
+ payload->comp_alg_list = item;
+ break;
+ }
+#else
+ if (silc_hmac_is_supported(item) == TRUE) {
+ SILC_LOG_DEBUG(("Found Compression `%s'", item));
+ payload->comp_alg_len = len;
+ payload->comp_alg_list = item;
break;
}
+#endif
cp += len;
if (strlen(cp) == 0)
if (item)
silc_free(item);
}
-
- if (!payload->hash_alg_len && !payload->hash_alg_list) {
- SILC_LOG_DEBUG(("Could not find supported hash alg"));
- silc_ske_abort(ske, SILC_SKE_STATUS_UNKNOWN_HASH_FUNCTION);
- silc_free(payload->ke_grp_list);
- silc_free(payload->pkcs_alg_list);
- silc_free(payload->enc_alg_list);
- silc_free(payload);
- return;
- }
- } else {
-
}
-#endif
payload->len = 1 + 1 + 2 + SILC_SKE_COOKIE_LEN +
2 + payload->version_len +
{
SilcSKEStatus status = SILC_SKE_STATUS_OK;
unsigned char *string;
+ SilcUInt32 l;
+
+ if (!len)
+ return SILC_SKE_STATUS_ERROR;
SILC_LOG_DEBUG(("Creating random number"));
+ l = ((len - 1) / 8);
+
/* Get the random number as string */
- string = silc_rng_get_rn_data(ske->rng, ((len - 1) / 8));
+ string = silc_rng_get_rn_data(ske->rng, l);
if (!string)
return SILC_SKE_STATUS_OUT_OF_MEMORY;
/* Decode the string into a MP integer */
- silc_mp_bin2mp(string, ((len - 1) / 8), rnd);
+ silc_mp_bin2mp(string, l, rnd);
silc_mp_mod_2exp(rnd, rnd, len);
/* Checks */
if (silc_mp_cmp(rnd, n) >= 0)
status = SILC_SKE_STATUS_ERROR;
- memset(string, 'F', (len / 8));
+ memset(string, 'F', l);
silc_free(string);
return status;
#include "silcincludes.h"
-/* Macro to check whether there is enough free space to add the
+/* Macros to check whether there is enough free space to add the
required amount of data. For unformatting this means that there must
be the data that is to be extracted. */
-#define MY_HAS_SPACE(__x__, __req__) \
+#define FORMAT_HAS_SPACE(__x__, __req__) \
do { \
if (__req__ > (__x__)->len) \
goto fail; \
} while(0)
+#define UNFORMAT_HAS_SPACE(__x__, __req__) \
+ do { \
+ if (__req__ > (__x__)->len) \
+ goto fail; \
+ if ((__req__ + 1) <= 0) \
+ goto fail; \
+ } while(0)
/* Formats the arguments sent and puts them into the buffer sent as
argument. The buffer must be initialized beforehand and it must have
case SILC_BUFFER_PARAM_SI8_CHAR:
{
char x = (char)va_arg(ap, int);
- MY_HAS_SPACE(dst, 1);
+ FORMAT_HAS_SPACE(dst, 1);
silc_buffer_put(dst, &x, 1);
silc_buffer_pull(dst, 1);
break;
case SILC_BUFFER_PARAM_UI8_CHAR:
{
unsigned char x = (unsigned char)va_arg(ap, int);
- MY_HAS_SPACE(dst, 1);
+ FORMAT_HAS_SPACE(dst, 1);
silc_buffer_put(dst, &x, 1);
silc_buffer_pull(dst, 1);
break;
{
unsigned char xf[2];
SilcInt16 x = (SilcInt16)va_arg(ap, int);
- MY_HAS_SPACE(dst, 2);
+ FORMAT_HAS_SPACE(dst, 2);
SILC_PUT16_MSB(x, xf);
silc_buffer_put(dst, xf, 2);
silc_buffer_pull(dst, 2);
{
unsigned char xf[2];
SilcUInt16 x = (SilcUInt16)va_arg(ap, int);
- MY_HAS_SPACE(dst, 2);
+ FORMAT_HAS_SPACE(dst, 2);
SILC_PUT16_MSB(x, xf);
silc_buffer_put(dst, xf, 2);
silc_buffer_pull(dst, 2);
{
unsigned char xf[4];
SilcInt32 x = va_arg(ap, SilcInt32);
- MY_HAS_SPACE(dst, 4);
+ FORMAT_HAS_SPACE(dst, 4);
SILC_PUT32_MSB(x, xf);
silc_buffer_put(dst, xf, 4);
silc_buffer_pull(dst, 4);
{
unsigned char xf[4];
SilcUInt32 x = va_arg(ap, SilcUInt32);
- MY_HAS_SPACE(dst, 4);
+ FORMAT_HAS_SPACE(dst, 4);
SILC_PUT32_MSB(x, xf);
silc_buffer_put(dst, xf, 4);
silc_buffer_pull(dst, 4);
{
unsigned char xf[8];
SilcInt64 x = va_arg(ap, SilcInt64);
- MY_HAS_SPACE(dst, sizeof(SilcInt64));
+ FORMAT_HAS_SPACE(dst, sizeof(SilcInt64));
SILC_PUT64_MSB(x, xf);
silc_buffer_put(dst, xf, sizeof(SilcInt64));
silc_buffer_pull(dst, sizeof(SilcInt64));
{
unsigned char xf[8];
SilcUInt64 x = va_arg(ap, SilcUInt64);
- MY_HAS_SPACE(dst, sizeof(SilcUInt64));
+ FORMAT_HAS_SPACE(dst, sizeof(SilcUInt64));
SILC_PUT64_MSB(x, xf);
silc_buffer_put(dst, xf, sizeof(SilcUInt64));
silc_buffer_pull(dst, sizeof(SilcUInt64));
{
unsigned char *x = va_arg(ap, unsigned char *);
SilcUInt32 tmp_len = strlen(x);
- MY_HAS_SPACE(dst, tmp_len);
+ FORMAT_HAS_SPACE(dst, tmp_len);
silc_buffer_put(dst, x, tmp_len);
silc_buffer_pull(dst, tmp_len);
break;
unsigned char *x = va_arg(ap, unsigned char *);
SilcUInt32 len = va_arg(ap, SilcUInt32);
if (x && len) {
- MY_HAS_SPACE(dst, len);
+ FORMAT_HAS_SPACE(dst, len);
silc_buffer_put(dst, x, len);
silc_buffer_pull(dst, len);
}
case SILC_BUFFER_PARAM_SI8_CHAR:
{
char *x = va_arg(ap, char *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
if (x)
*x = src->data[0];
silc_buffer_pull(src, 1);
case SILC_BUFFER_PARAM_UI8_CHAR:
{
unsigned char *x = va_arg(ap, unsigned char *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
if (x)
*x = src->data[0];
silc_buffer_pull(src, 1);
case SILC_BUFFER_PARAM_SI16_SHORT:
{
SilcInt16 *x = va_arg(ap, SilcInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
if (x)
SILC_GET16_MSB(*x, src->data);
silc_buffer_pull(src, 2);
case SILC_BUFFER_PARAM_UI16_SHORT:
{
SilcUInt16 *x = va_arg(ap, SilcUInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
if (x)
SILC_GET16_MSB(*x, src->data);
silc_buffer_pull(src, 2);
case SILC_BUFFER_PARAM_SI32_INT:
{
SilcInt32 *x = va_arg(ap, SilcInt32 *);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
if (x)
SILC_GET32_MSB(*x, src->data);
silc_buffer_pull(src, 4);
case SILC_BUFFER_PARAM_UI32_INT:
{
SilcUInt32 *x = va_arg(ap, SilcUInt32 *);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
if (x)
SILC_GET32_MSB(*x, src->data);
silc_buffer_pull(src, 4);
case SILC_BUFFER_PARAM_SI64_INT:
{
SilcInt64 *x = va_arg(ap, SilcInt64 *);
- MY_HAS_SPACE(src, sizeof(SilcInt64));
+ UNFORMAT_HAS_SPACE(src, sizeof(SilcInt64));
if (x)
SILC_GET64_MSB(*x, src->data);
silc_buffer_pull(src, sizeof(SilcInt64));
case SILC_BUFFER_PARAM_UI64_INT:
{
SilcUInt64 *x = va_arg(ap, SilcUInt64 *);
- MY_HAS_SPACE(src, sizeof(SilcUInt64));
+ UNFORMAT_HAS_SPACE(src, sizeof(SilcUInt64));
if (x)
SILC_GET64_MSB(*x, src->data);
silc_buffer_pull(src, sizeof(SilcUInt64));
{
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x)
*x = src->data;
silc_buffer_pull(src, len2);
{
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x)
*x = src->data;
silc_buffer_pull(src, len2);
{
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x && len2) {
*x = silc_calloc(len2 + 1, sizeof(unsigned char));
memcpy(*x, src->data, len2);
{
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x && len2) {
*x = silc_calloc(len2 + 1, sizeof(unsigned char));
memcpy(*x, src->data, len2);
{
SilcUInt32 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
SILC_GET32_MSB(len2, src->data);
silc_buffer_pull(src, 4);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x)
*x = src->data;
silc_buffer_pull(src, len2);
{
SilcUInt32 len2;
unsigned char **x = va_arg(ap, unsigned char **);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
SILC_GET32_MSB(len2, src->data);
silc_buffer_pull(src, 4);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (x && len2) {
*x = silc_calloc(len2 + 1, sizeof(unsigned char));
memcpy(*x, src->data, len2);
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt8 *len = va_arg(ap, SilcUInt8 *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x)
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt16 *len = va_arg(ap, SilcUInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x)
SilcUInt8 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt8 *len = va_arg(ap, SilcUInt8 *);
- MY_HAS_SPACE(src, 1);
+ UNFORMAT_HAS_SPACE(src, 1);
len2 = (SilcUInt8)src->data[0];
silc_buffer_pull(src, 1);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x && len2) {
SilcUInt16 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt16 *len = va_arg(ap, SilcUInt16 *);
- MY_HAS_SPACE(src, 2);
+ UNFORMAT_HAS_SPACE(src, 2);
SILC_GET16_MSB(len2, src->data);
silc_buffer_pull(src, 2);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x && len2) {
SilcUInt32 len2;
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt32 *len = va_arg(ap, SilcUInt32 *);
- MY_HAS_SPACE(src, 4);
+ UNFORMAT_HAS_SPACE(src, 4);
SILC_GET32_MSB(len2, src->data);
silc_buffer_pull(src, 4);
- MY_HAS_SPACE(src, len2);
+ UNFORMAT_HAS_SPACE(src, len2);
if (len)
*len = len2;
if (x)
{
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt32 len = va_arg(ap, SilcUInt32);
- MY_HAS_SPACE(src, len);
+ UNFORMAT_HAS_SPACE(src, len);
if (len && x)
*x = src->data;
silc_buffer_pull(src, len);
{
unsigned char **x = va_arg(ap, unsigned char **);
SilcUInt32 len = va_arg(ap, SilcUInt32);
- MY_HAS_SPACE(src, len);
+ UNFORMAT_HAS_SPACE(src, len);
if (len && x) {
*x = silc_calloc(len + 1, sizeof(unsigned char));
memcpy(*x, src->data, len);
/* unique for each config file (and included ones) */
struct SilcConfigFileObject {
- char *filename; /* the original filename opened */
- int level; /* parsing level, how many nested silc_config_main we have */
- char *base; /* this is a fixed pointer to the base location */
- char *p; /* the Parser poitner */
+ char *filename; /* the original filename opened */
+ int level; /* parsing level, how many nested
+ silc_config_main we have */
+ char *base; /* this is a fixed pointer to the base location */
+ char *p; /* the Parser poitner */
SilcUInt32 len; /* fixed length of the whole file */
SilcUInt32 line; /* current parsing line, strictly linked to p */
- bool included; /* wether this file is main or included */
+ bool included; /* wether this file is main or included */
};
/* We need the entity to base our block-style parsing on */
/* access error descriptions only with silc_config_strerror() */
static char *errorstrs[] = {
- "-OK", /* SILC_CONFIG_OK */
- "-SILENT", /* SILC_CONFIG_ESILENT */
- "-PRINTLINE", /* SILC_CONFIG_EPRINTLINE */
- "Invalid syntax", /* SILC_CONFIG_EGENERIC */
- "Internal error! Please report this bug", /* SILC_CONFIG_EINTERNAL */
- "Can't open specified file", /* SILC_CONFIG_ECANTOPEN */
- "Expected open-brace '{'", /* SILC_CONFIG_EOPENBRACE */
- "Missing close-brace '}'", /* SILC_CONFIG_ECLOSEBRACE */
- "Invalid data type", /* SILC_CONFIG_ETYPE */
- "Unknown option", /* SILC_CONFIG_EBADOPTION */
- "Invalid text", /* SILC_CONFIG_EINVALIDTEXT */
- "Double option specification", /* SILC_CONFIG_EDOUBLE */
- "Expected data but not found", /* SILC_CONFIG_EEXPECTED */
- "Expected '='", /* SILC_CONFIG_EEXPECTEDEQUAL */
- "Unexpected data", /* SILC_CONFIG_EUNEXPECTED */
- "Missing mandatory fields", /* SILC_CONFIG_EMISSFIELDS */
- "Missing ';'", /* SILC_CONFIG_EMISSCOLON */
+ "-OK", /* SILC_CONFIG_OK */
+ "-SILENT", /* SILC_CONFIG_ESILENT */
+ "-PRINTLINE", /* SILC_CONFIG_EPRINTLINE */
+ "Invalid syntax", /* SILC_CONFIG_EGENERIC */
+ "Internal error! Please report this bug", /* SILC_CONFIG_EINTERNAL */
+ "Can't open specified file", /* SILC_CONFIG_ECANTOPEN */
+ "Expected open-brace '{'", /* SILC_CONFIG_EOPENBRACE */
+ "Missing close-brace '}'", /* SILC_CONFIG_ECLOSEBRACE */
+ "Invalid data type", /* SILC_CONFIG_ETYPE */
+ "Unknown option", /* SILC_CONFIG_EBADOPTION */
+ "Invalid text", /* SILC_CONFIG_EINVALIDTEXT */
+ "Double option specification", /* SILC_CONFIG_EDOUBLE */
+ "Expected data but not found", /* SILC_CONFIG_EEXPECTED */
+ "Expected '='", /* SILC_CONFIG_EEXPECTEDEQUAL */
+ "Unexpected data", /* SILC_CONFIG_EUNEXPECTED */
+ "Missing mandatory fields", /* SILC_CONFIG_EMISSFIELDS */
+ "Missing ';'", /* SILC_CONFIG_EMISSCOLON */
};
/* return string describing SilcConfig's error code */
{
register char *p;
int len;
- char *ret, *endbuf;
+ char *ret = NULL, *endbuf;
if (!file || (line <= 0))
return NULL;
found:
if ((endbuf = strchr(p, '\n'))) {
len = endbuf - p;
- ret = silc_memdup(p, len);
+ if (len > 0)
+ ret = silc_memdup(p, len);
} else {
ret = silc_memdup(p, strlen(p));
}
const SilcConfigTable *subtable, void *context)
{
SilcConfigOption *newopt;
- SILC_CONFIG_DEBUG(("Register new option=\"%s\" type=%u cb=0x%08x context=0x%08x",
- name, type, (SilcUInt32) cb, (SilcUInt32) context));
+ SILC_CONFIG_DEBUG(("Register new option=\"%s\" "
+ "type=%u cb=0x%08x context=0x%08x",
+ name, type, (SilcUInt32) cb, (SilcUInt32) context));
/* if we are registering a block, make sure there is a specified sub-table */
if (!ent || !name || ((type == SILC_CONFIG_ARG_BLOCK) && !subtable))
/* obtain the keyword */
my_next_token(file, buf);
- SILC_CONFIG_DEBUG(("Looking up keyword=\"%s\" [line=%lu]", buf, file->line));
+ SILC_CONFIG_DEBUG(("Looking up keyword=\"%s\" [line=%lu]",
+ buf, file->line));
/* handle special directive */
if (!strcasecmp(buf, "include")) {
/*
- silcschedule.c
+ silcschedule.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1998 - 2001 Pekka Riikonen
+ Copyright (C) 1998 - 2002 Pekka Riikonen
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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
static void silc_schedule_dispatch_nontimeout(SilcSchedule schedule)
{
SilcTask task;
- int i, last_fd = schedule->last_fd;
- SilcUInt32 fd;
+ int i;
+ SilcUInt32 fd, last_fd = schedule->last_fd;
for (i = 0; i <= last_fd; i++) {
if (schedule->fd_list[i].events == 0)