=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/arguments.c,v retrieving revision 1.8 retrieving revision 1.9 diff -c -r1.8 -r1.9 *** src/usr.bin/tmux/arguments.c 2014/01/15 11:44:18 1.8 --- src/usr.bin/tmux/arguments.c 2014/04/11 19:35:54 1.9 *************** *** 1,4 **** ! /* $OpenBSD: arguments.c,v 1.8 2014/01/15 11:44:18 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: arguments.c,v 1.9 2014/04/11 19:35:54 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott *************** *** 125,131 **** size_t args_print(struct args *args, char *buf, size_t len) { ! size_t off; int i; const char *quotes; struct args_entry *entry; --- 125,131 ---- size_t args_print(struct args *args, char *buf, size_t len) { ! size_t off, used; int i; const char *quotes; struct args_entry *entry; *************** *** 165,173 **** quotes = "\""; else quotes = ""; ! off += xsnprintf(buf + off, len - off, "%s-%c %s%s%s", off != 0 ? " " : "", entry->flag, quotes, entry->value, quotes); } /* And finally the argument vector. */ --- 165,176 ---- quotes = "\""; else quotes = ""; ! 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,188 **** quotes = "\""; else quotes = ""; ! off += xsnprintf(buf + off, len - off, "%s%s%s%s", off != 0 ? " " : "", quotes, args->argv[i], quotes); } return (off); --- 184,194 ---- quotes = "\""; else quotes = ""; ! 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);