ossp-pkg/var/var.c 1.34 -> 1.35
--- var.c 2001/11/20 14:04:06 1.34
+++ var.c 2001/11/20 15:36:42 1.35
@@ -1311,9 +1311,9 @@
case '#': /* Substitute length of the string. */
if (data->begin) {
- char buf[32]; //FIXME: thl 2^64 would fit into 20chars ...
- sprintf(buf, "%d", data->end - data->begin);
- tokenbuf_free(data);
+ char buf[((sizeof(int)*8)/3)+10]; /* sufficient size: <#bits> x log_10(2) + safety */
+ sprintf(buf, "%d", (int)(data->end - data->begin));
+ tokenbuf_free(data);
if (!tokenbuf_assign(data, buf, strlen(buf))) {
rc = VAR_ERR_OUT_OF_MEMORY;
goto error_return;
|
|