From dd4e99c9d7111fe1fab9b0a968c1321425f83429 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 16 Dec 2007 00:03:56 +0100 Subject: Remove a static fstring (This used to be commit a9c62c57db9e580640d0265b08b3178496de76a8) --- source3/lib/version.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/lib/version.c b/source3/lib/version.c index ca334a27d9..204c2044a8 100644 --- a/source3/lib/version.c +++ b/source3/lib/version.c @@ -19,33 +19,41 @@ */ #include "includes.h" +#include const char *samba_version_string(void) { #ifndef SAMBA_VERSION_VENDOR_SUFFIX return SAMBA_VERSION_OFFICIAL_STRING; #else - static fstring samba_version; - static bool init_samba_version; + static char *samba_version; + int res; #ifdef SAMBA_VERSION_VENDOR_PATCH - fstring tmp_version; - size_t remaining; + char *tmp_version; #endif - if (init_samba_version) + if (samba_version != NULL) return samba_version; - snprintf(samba_version,sizeof(samba_version),"%s-%s", - SAMBA_VERSION_OFFICIAL_STRING, - SAMBA_VERSION_VENDOR_SUFFIX); + res = asprintf(&samba_version, "%s-%s", + SAMBA_VERSION_OFFICIAL_STRING, + SAMBA_VERSION_VENDOR_SUFFIX); + /* + * Can't use smb_panic here due to dependencies + */ + assert(res != -1); #ifdef SAMBA_VERSION_VENDOR_PATCH - remaining = sizeof(samba_version)-strlen(samba_version); - snprintf( tmp_version, sizeof(tmp_version), "-%d", SAMBA_VERSION_VENDOR_PATCH ); - strlcat( samba_version, tmp_version, remaining-1 ); + res = asprintf(&tmp_version, "%s-%d", samba_version, + SAMBA_VERSION_VENDOR_PATCH); + /* + * Can't use smb_panic here due to dependencies + */ + assert(res != -1); + + samba_version = tmp_version; #endif - init_samba_version = True; return samba_version; #endif } -- cgit