GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
+#include <assert.h>
const char *samba_version_string(void)
{
#ifndef SAMBA_VERSION_VENDOR_SUFFIX
return SAMBA_VERSION_OFFICIAL_STRING;
#else
- static fstring samba_version;
- fstring tmp_version;
- static BOOL init_samba_version;
- size_t remaining;
+ static char *samba_version;
+ int res;
+#ifdef SAMBA_VERSION_VENDOR_PATCH
+ 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
+ res = asprintf(&tmp_version, "%s-%d", samba_version,
+ SAMBA_VERSION_VENDOR_PATCH);
+ /*
+ * Can't use smb_panic here due to dependencies
+ */
+ assert(res != -1);
-#ifdef SAMBA_VENDOR_PATCH
- remaining = sizeof(samba_version)-strlen(samba_version);
- snprintf( tmp_version, sizeof(tmp_version), "-%d", SAMBA_VENDOR_PATCH );
- strlcat( samba_version, tmp_version, remaining-1 );
+ samba_version = tmp_version;
#endif
- init_samba_version = True;
return samba_version;
#endif
}