diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-04-05 15:57:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-04-05 15:57:12 +0000 |
commit | fefc90a99d5708759b81ae163724489ad480139a (patch) | |
tree | 6ba47a819cef26f8b98c1e470bd5136cd65475d8 /usr.bin/systat/engine.c | |
parent | 28b1fe5d6b9ba2118f934557d3d0d22a3ae83eef (diff) |
Clamp size to length if snprintf ever indicates overflow
w/ millert
Diffstat (limited to 'usr.bin/systat/engine.c')
-rw-r--r-- | usr.bin/systat/engine.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/systat/engine.c b/usr.bin/systat/engine.c index 2844f873ee6..64cfc86d334 100644 --- a/usr.bin/systat/engine.c +++ b/usr.bin/systat/engine.c @@ -1,4 +1,4 @@ -/* $Id: engine.c,v 1.20 2017/04/05 04:44:03 deraadt Exp $ */ +/* $Id: engine.c,v 1.21 2017/04/05 15:57:11 deraadt Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org> * @@ -347,6 +347,8 @@ print_bar_title(field_def *fld) } len = snprintf(buf, sizeof(buf), "%d\\", val); + if (len >= sizeof(buf)) + len = strlen(buf); while (cur < pos - len) { tbprintf(" "); cur++; |