From: Pekka Riikonen Date: Mon, 23 Feb 2004 16:51:08 +0000 (+0000) Subject: Define SILC_STRFMT_END for silc_buffer_strformat that now X-Git-Tag: silc.server.0.9.17~6 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=e4db943aea034e9c5ee94c39f084539b7aa9aaf0;p=silc.git Define SILC_STRFMT_END for silc_buffer_strformat that now must be used instead of SILC_STR_END. --- diff --git a/CHANGES b/CHANGES index 81c054dc..6025100e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Mon Feb 23 23:31:15 EET 2004 Pekka Riikonen + + * Defined SILC_STRFMT_END that must be used now with + silc_buffer_strformat, instead of SILC_STR_END. Fixes + crashes on AMD64. Affected files are lib/silcutil/silcbuffmt.h, + lib/silcclient/silcvcard.c, silcd/server_util.c. + Mon Feb 23 09:30:30 CET 2004 Pekka Riikonen * Added support for public key watching in server. Affected diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 56791fab..48c6f305 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -1704,8 +1704,8 @@ silc_server_check_watcher_list_foreach(void *key, void *context, } } -/* This function checks whether the `client' nickname and/or 'client' - public key is being watched by someone, and notifies the watcher of the +/* This function checks whether the `client' nickname and/or 'client' + public key is being watched by someone, and notifies the watcher of the notify change of notify type indicated by `notify'. */ bool silc_server_check_watcher_list(SilcServer server, @@ -1747,7 +1747,7 @@ bool silc_server_check_watcher_list(SilcServer server, if (client->data.public_key) silc_hash_table_find_foreach(server->watcher_list_pk, client->data.public_key, - silc_server_check_watcher_list_foreach, + silc_server_check_watcher_list_foreach, &n); return TRUE; @@ -1934,8 +1934,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, if (len) { if (tmp[len - 1] == ',') tmp[len - 1] = '\0'; - silc_buffer_strformat(tmp2, tmp, SILC_STR_END); - silc_buffer_strformat(tmp2, ",", SILC_STR_END); + silc_buffer_strformat(tmp2, tmp, SILC_STRFMT_END); + silc_buffer_strformat(tmp2, ",", SILC_STRFMT_END); } } else { /* Announced list. Check each entry in the list */ @@ -1972,8 +1972,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, /* Save the part that we didn't already have. */ if (strlen(rtmp) > 1) { - silc_buffer_strformat(tmp2, rtmp, SILC_STR_END); - silc_buffer_strformat(tmp2, ",", SILC_STR_END); + silc_buffer_strformat(tmp2, rtmp, SILC_STRFMT_END); + silc_buffer_strformat(tmp2, ",", SILC_STRFMT_END); } silc_free(rtmp); } diff --git a/lib/silcutil/silcbuffmt.c b/lib/silcutil/silcbuffmt.c index a189c290..65dd76b4 100644 --- a/lib/silcutil/silcbuffmt.c +++ b/lib/silcutil/silcbuffmt.c @@ -524,7 +524,7 @@ int silc_buffer_strformat(SilcBuffer dst, ...) /* Parse the arguments by formatting type. */ while(1) { - char *string = va_arg(va, char *); + char *string = (char *)va_arg(va, void *); if (!string) continue; diff --git a/lib/silcutil/silcbuffmt.h b/lib/silcutil/silcbuffmt.h index 86c155e3..3ffc7499 100644 --- a/lib/silcutil/silcbuffmt.h +++ b/lib/silcutil/silcbuffmt.h @@ -1,10 +1,10 @@ /* - silcbuffmt.h + silcbuffmt.h Author: Pekka Riikonen - Copyright (C) 1997 - 2003 Pekka Riikonen + Copyright (C) 1997 - 2004 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 @@ -122,14 +122,14 @@ int silc_buffer_unformat_vp(SilcBuffer src, va_list ap); * * Formats a buffer from variable argument list of strings. Each * string must be NULL-terminated and the variable argument list must - * be end with SILC_STR_END argument. This allows that a string in + * be end with SILC_STRFMT_END argument. This allows that a string in * the list can be NULL, in which case it is skipped. This automatically * allocates the space for the buffer data but `dst' must be already * allocated by the caller. * * EXAMPLE * - * ret = silc_buffer_strformat(buffer, "foo", "bar", SILC_STR_END); + * ret = silc_buffer_strformat(buffer, "foo", "bar", SILC_STRFMT_END); * if (ret < 0) * error; * @@ -292,7 +292,7 @@ typedef enum { * automatically. * * Example: - * + * * Formatting: ..., SILC_STR_UI_INT(strlen(string)), * SILC_STR_UI32_STRING(string), ... * Unformatting: ..., SILC_STR_UI32_STRING(&string), ... @@ -412,4 +412,18 @@ typedef enum { ***/ #define SILC_STR_END SILC_BUFFER_PARAM_END +/****d* silcutil/SilcBufferFormatAPI/SILC_STRFMT_END + * + * NAME + * + * #define SILC_STRFMT_END ... + * + * DESCRIPTION + * + * Marks end of the argument list in silc_buffer_strformat function. + * This must be at the end of the argument list or error will occur. + * + ***/ +#define SILC_STRFMT_END (void *)SILC_STR_END + #endif /* !SILCBUFFMT_H */ diff --git a/lib/silcutil/silcvcard.c b/lib/silcutil/silcvcard.c index a6d6fd5b..6776a31c 100644 --- a/lib/silcutil/silcvcard.c +++ b/lib/silcutil/silcvcard.c @@ -1,6 +1,6 @@ /* - silcvcard.c + silcvcard.c Author: Pekka Riikonen @@ -43,44 +43,44 @@ unsigned char *silc_vcard_encode(SilcVCard vcard, SilcUInt32 *vcard_len) "FN:", vcard->full_name, "\n", "N:", vcard->family_name, ";", vcard->first_name, ";", vcard->middle_names, ";", vcard->prefix, ";", vcard->suffix, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->nickname) silc_buffer_strformat(&buffer, "NICKNAME:", vcard->nickname, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->bday) silc_buffer_strformat(&buffer, "BDAY:", vcard->bday, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->title) silc_buffer_strformat(&buffer, "TITLE:", vcard->title, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->role) silc_buffer_strformat(&buffer, "ROLE:", vcard->role, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->org_name) silc_buffer_strformat(&buffer, "ORG:", vcard->org_name, ";", vcard->org_unit, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->categories) silc_buffer_strformat(&buffer, "CATEGORIES:", vcard->categories, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->catclass) silc_buffer_strformat(&buffer, "CLASS:", vcard->catclass, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->url) silc_buffer_strformat(&buffer, "URL:", vcard->url, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->label) silc_buffer_strformat(&buffer, "LABEL;", vcard->url, "\n", - SILC_STR_END); + SILC_STRFMT_END); for (i = 0; i < vcard->num_addrs; i++) { silc_buffer_strformat(&buffer, "ADR;TYPE=", @@ -92,32 +92,32 @@ unsigned char *silc_vcard_encode(SilcVCard vcard, SilcUInt32 *vcard_len) vcard->addrs[i].state, ";", vcard->addrs[i].code, ";", vcard->addrs[i].country, "\n", - SILC_STR_END); + SILC_STRFMT_END); } for (i = 0; i < vcard->num_tels; i++) { silc_buffer_strformat(&buffer, "TEL;TYPE=", vcard->tels[i].type, ":", vcard->tels[i].telnum, "\n", - SILC_STR_END); + SILC_STRFMT_END); } for (i = 0; i < vcard->num_emails; i++) { silc_buffer_strformat(&buffer, "EMAIL;TYPE=", vcard->emails[i].type, ":", vcard->emails[i].address, "\n", - SILC_STR_END); + SILC_STRFMT_END); } if (vcard->note) silc_buffer_strformat(&buffer, "NOTE:", vcard->note, "\n", - SILC_STR_END); + SILC_STRFMT_END); if (vcard->rev) silc_buffer_strformat(&buffer, "REV:", vcard->rev, "\n", - SILC_STR_END); + SILC_STRFMT_END); - silc_buffer_strformat(&buffer, VCARD_FOOTER, SILC_STR_END); + silc_buffer_strformat(&buffer, VCARD_FOOTER, SILC_STRFMT_END); if (vcard_len) *vcard_len = buffer.truelen; @@ -174,7 +174,7 @@ bool silc_vcard_decode(const unsigned char *data, SilcUInt32 data_len, unsigned char *val; bool has_begin = FALSE, has_end = FALSE; int len, i, off = 0; - + val = (unsigned char *)data; while (val) { len = 0;