Author: iratqq
Date: Thu Apr 10 19:47:30 2008
New Revision: 5403
Modified:
trunk/COPYING
trunk/uim/uim-error.c
trunk/uim/uim.h
Log:
* uim/uim-error.c (uim_asprintf):
- New function from openssh/xmalloc.c
"len = strlen(buf); snprintf(buf, len, ...);"
is bogus. Please use it.
Modified: trunk/COPYING
==============================================================================
--- trunk/COPYING (original)
+++ trunk/COPYING Thu Apr 10 19:47:30 2008
@@ -132,3 +132,19 @@
[EMAIL PROTECTED]
MORIBE, Hideyuki
-----------------------------------------------------------------------------
+
+
+uim/uim-error.c(uim_asprintf) is covered by:
+-----------------------------------------------------------------------------
+Author: Tatu Ylonen <[EMAIL PROTECTED]>
+Copyright (c) 1995 Tatu Ylonen <[EMAIL PROTECTED]>, Espoo, Finland
+ All rights reserved
+Versions of malloc and friends that check their results, and never return
+failure (they call fatal if they encounter an error).
+
+As far as I am concerned, the code I have written for this software
+can be used freely for any purpose. Any derived versions of this
+software must be clearly marked as such, and if the derived work is
+incompatible with the protocol description in the RFC file, it must be
+called by a name other than "ssh" or "Secure Shell".
+-----------------------------------------------------------------------------
Modified: trunk/uim/uim-error.c
==============================================================================
--- trunk/uim/uim-error.c (original)
+++ trunk/uim/uim-error.c Thu Apr 10 19:47:30 2008
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <stdarg.h>
#include <assert.h>
#if HAVE_SYSEXITS_H
#include "sysexits.h"
@@ -224,4 +225,20 @@
#endif
return copied;
+}
+
+int
+uim_asprintf(char **ret, const char *fmt, ...)
+{
+ va_list ap;
+ int i;
+
+ va_start(ap, fmt);
+ i = vasprintf(ret, fmt, ap);
+ va_end(ap);
+
+ if (i < 0 || *ret == NULL)
+ uim_fatal_error("asprintf() failed");
+
+ return i;
}
Modified: trunk/uim/uim.h
==============================================================================
--- trunk/uim/uim.h (original)
+++ trunk/uim/uim.h Thu Apr 10 19:47:30 2008
@@ -926,6 +926,8 @@
void *uim_realloc(void *p, size_t size);
void *uim_calloc(size_t nmemb, size_t size);
char *uim_strdup(const char *s);
+int uim_asprintf(char **, const char *, ...);
+
#ifdef __cplusplus
}