diff options
author | Thomas Adam <thomas@xteddy.org> | 2014-04-23 11:26:11 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2014-04-23 11:26:11 +0100 |
commit | 953c3ef47a1933d38308075c1bacc7ea8d38301b (patch) | |
tree | 6484bdd51ecedbb5888717db271c151257ec87f5 /arguments.c | |
parent | 12e9c974fadc5ed6f0e7db10c40d5a0d55e0da8a (diff) | |
parent | 64613b9d411a7c76a50a2f9c66df345f082fce25 (diff) | |
download | rtmux-953c3ef47a1933d38308075c1bacc7ea8d38301b.tar.gz rtmux-953c3ef47a1933d38308075c1bacc7ea8d38301b.tar.bz2 rtmux-953c3ef47a1933d38308075c1bacc7ea8d38301b.zip |
Merge branch 'obsd-master'
Conflicts:
Makefile
tmux.1
window.c
Diffstat (limited to 'arguments.c')
-rw-r--r-- | arguments.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/arguments.c b/arguments.c index d4e5e53f..fd656b14 100644 --- a/arguments.c +++ b/arguments.c @@ -125,7 +125,7 @@ args_free(struct args *args) size_t args_print(struct args *args, char *buf, size_t len) { - size_t off; + size_t off, used; int i; const char *quotes; struct args_entry *entry; @@ -165,9 +165,12 @@ args_print(struct args *args, char *buf, size_t len) quotes = "\""; else quotes = ""; - off += xsnprintf(buf + off, len - off, "%s-%c %s%s%s", + used = xsnprintf(buf + off, len - off, "%s-%c %s%s%s", off != 0 ? " " : "", entry->flag, quotes, entry->value, quotes); + if (used > len - off) + used = len - off; + off += used; } /* And finally the argument vector. */ @@ -181,8 +184,11 @@ args_print(struct args *args, char *buf, size_t len) quotes = "\""; else quotes = ""; - off += xsnprintf(buf + off, len - off, "%s%s%s%s", + used = xsnprintf(buf + off, len - off, "%s%s%s%s", off != 0 ? " " : "", quotes, args->argv[i], quotes); + if (used > len - off) + used = len - off; + off += used; } return (off); |