diff options
author | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2003-04-19 23:55:06 +0000 |
---|---|---|
committer | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2003-04-19 23:55:06 +0000 |
commit | e163a1b56f4209b680b60fb409f6d0587e8412dc (patch) | |
tree | 991685cb0a58c3206b115e6e82502dbe4f70a646 /usr.bin | |
parent | 1a45a4d143726cc243e2b02109286317a602ad73 (diff) |
string handling, partly from and ok deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sectok/cyberflex.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/sectok/cyberflex.c b/usr.bin/sectok/cyberflex.c index 3503ba65de2..2672da30d14 100644 --- a/usr.bin/sectok/cyberflex.c +++ b/usr.bin/sectok/cyberflex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cyberflex.c,v 1.24 2003/04/04 00:51:10 deraadt Exp $ */ +/* $OpenBSD: cyberflex.c,v 1.25 2003/04/19 23:55:05 dhartmei Exp $ */ /* * copyright 1999, 2000 @@ -365,7 +365,7 @@ print_acl(int isdir, u_char *acl) } void -sectok_fmt_aidname(char *aidname, int aidlen, u_char *aid) +sectok_fmt_aidname(char *aidname, int aidlen, u_char *aid, size_t len) { int i, istext = 1; @@ -375,13 +375,16 @@ sectok_fmt_aidname(char *aidname, int aidlen, u_char *aid) break; } if (istext) { + if (aidlen + 1 > len) + aidlen = len - 1; memcpy(aidname, aid, aidlen); aidname[aidlen] = '\0'; if (aid[0] == 0xfc) aidname[0] = '#'; } else { for (i = 0; i < aidlen; i++) - sprintf(&aidname[i * 2], "%02x", aid[i]); + snprintf(&aidname[i * 2], len - ( i * 2), + "%02x", aid[i]); } } @@ -440,7 +443,8 @@ ls(int argc, char *argv[]) if (buflen > 23 && buf[23]) { aidname[0] = ' '; sectok_fmt_aidname(&aidname[1], - buf[23], &buf[24]); + buf[23], &buf[24], + sizeof aidname - 1); } } else snprintf(ftype, sizeof ftype, |