summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-15 08:08:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-15 08:08:03 +0000
commit1bdbc641dedd5ac26832ac889dbe8ea443615908 (patch)
tree8df29c690cdff41b5c7f8fad6ef60757987ef5d8 /usr.bin/vi
parent4811e2346a9cc59d51c5a0df470c93da5cfaf390 (diff)
snprintf of course
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/common/api.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/vi/common/api.c b/usr.bin/vi/common/api.c
index 38bf9bcda28..1c796467336 100644
--- a/usr.bin/vi/common/api.c
+++ b/usr.bin/vi/common/api.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: api.c,v 1.11 2002/02/16 21:27:56 millert Exp $ */
+/* $OpenBSD: api.c,v 1.12 2003/04/15 08:08:02 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -425,6 +425,7 @@ api_opts_get(sp, name, value, boolvalue)
{
OPTLIST const *op;
int offset;
+ size_t len;
if ((op = opts_search(name)) == NULL) {
opts_nomatch(sp, name);
@@ -437,24 +438,27 @@ api_opts_get(sp, name, value, boolvalue)
switch (op->type) {
case OPT_0BOOL:
case OPT_1BOOL:
- MALLOC_RET(sp, *value, char *, strlen(op->name) + 2 + 1);
- (void)sprintf(*value,
+ len = strlen(op->name) + 2 + 1;
+ MALLOC_RET(sp, *value, char *, len);
+ (void)snprintf(*value, len,
"%s%s", O_ISSET(sp, offset) ? "" : "no", op->name);
if (boolvalue != NULL)
*boolvalue = O_ISSET(sp, offset);
break;
case OPT_NUM:
- MALLOC_RET(sp, *value, char *, 20);
- (void)sprintf(*value, "%lu", (u_long)O_VAL(sp, offset));
+ len = 20;
+ MALLOC_RET(sp, *value, char *, len);
+ (void)snprintf(*value, len, "%lu", (u_long)O_VAL(sp, offset));
break;
case OPT_STR:
if (O_STR(sp, offset) == NULL) {
MALLOC_RET(sp, *value, char *, 2);
value[0] = '\0';
} else {
+ len = strlen(O_STR(sp, offset)) + 1;
MALLOC_RET(sp,
- *value, char *, strlen(O_STR(sp, offset)) + 1);
- (void)sprintf(*value, "%s", O_STR(sp, offset));
+ *value, char *, len);
+ (void)snprintf(*value, len, "%s", O_STR(sp, offset));
}
break;
}