Define SILC_STRFMT_END for silc_buffer_strformat that now
authorPekka Riikonen <priikone@silcnet.org>
Mon, 23 Feb 2004 16:51:08 +0000 (16:51 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 23 Feb 2004 16:51:08 +0000 (16:51 +0000)
must be used instead of SILC_STR_END.

CHANGES
apps/silcd/server_util.c
lib/silcutil/silcbuffmt.c
lib/silcutil/silcbuffmt.h
lib/silcutil/silcvcard.c

diff --git a/CHANGES b/CHANGES
index 81c054dc3de863b9b83ec9c0fb4cf5b414014511..6025100e1893f602b7982319eec051b9af56f594 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+Mon Feb 23 23:31:15 EET 2004  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Added support for public key watching in server.  Affected
index 56791fab71edc47556413ba88afdda94ac410797..48c6f30599613fb6fce9ef466031d44462bf4173 100644 (file)
@@ -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);
        }
index a189c2903a7e145fb6ccc88ee9fbd31e4b4d298a..65dd76b42c6ac102e7988b72851f6eecafbb8430 100644 (file)
@@ -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;
index 86c155e3a7bb65cd143cfacafa3398b4db365c22..3ffc74991f7972a501b65809ab8a1a8c51272219 100644 (file)
@@ -1,10 +1,10 @@
 /*
 
-  silcbuffmt.h 
+  silcbuffmt.h
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  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 */
index a6d6fd5bd655e33ccbdf99bf51241553e31a5b4e..6776a31c13e49273c380441b1b30b76d0b91a4b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
 
-  silcvcard.c 
+  silcvcard.c
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
@@ -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;