From: millert Date: Sun, 15 Sep 1996 23:13:03 +0000 (+0000) Subject: sprintf -> snprintf paranoia X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b1be319170c29c577d8c8cff003c57d53974e7ae;p=openbsd sprintf -> snprintf paranoia --- diff --git a/bin/stty/print.c b/bin/stty/print.c index 8090d2a7817..1e1e6af1df7 100644 --- a/bin/stty/print.c +++ b/bin/stty/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.4 1996/08/02 12:10:39 deraadt Exp $ */ +/* $OpenBSD: print.c,v 1.5 1996/09/15 23:13:03 millert Exp $ */ /* $NetBSD: print.c,v 1.11 1996/05/07 18:20:10 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.4 1996/08/02 12:10:39 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.5 1996/09/15 23:13:03 millert Exp $"; #endif #endif /* not lint */ @@ -193,8 +193,10 @@ print(tp, wp, ldisc, fmt) if (fmt != BSD && cc[p->sub] == p->def) continue; #define WD "%-8s" - (void)sprintf(buf1 + cnt * 8, WD, p->name); - (void)sprintf(buf2 + cnt * 8, WD, ccval(p, cc[p->sub])); + (void)snprintf(buf1 + cnt * 8, sizeof(buf1) - cnt * 8, + WD, p->name); + (void)snprintf(buf2 + cnt * 8, sizeof(buf2) - cnt * 8, + WD, ccval(p, cc[p->sub])); if (++cnt == LINELENGTH / 8) { cnt = 0; (void)printf("%s\n", buf1); diff --git a/kerberosIV/acl/acl_files.c b/kerberosIV/acl/acl_files.c index 03dd041d60b..79866892ff6 100644 --- a/kerberosIV/acl/acl_files.c +++ b/kerberosIV/acl/acl_files.c @@ -1,4 +1,4 @@ -/* $Id: acl_files.c,v 1.2 1995/12/14 08:43:39 tholo Exp $ */ +/* $Id: acl_files.c,v 1.3 1996/09/15 23:17:59 millert Exp $ */ /*- * Copyright (C) 1989 by the Massachusetts Institute of Technology @@ -143,7 +143,7 @@ acl_lock_file(acl_file) if(stat(acl_file, &s) < 0) return(NULL); mode = s.st_mode; - sprintf(new, NEW_FILE, acl_file); + snprintf(new, sizeof(new), NEW_FILE, acl_file); for(;;) { /* Open the new file */ if((nfd = open(new, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) { @@ -193,7 +193,7 @@ acl_abort(acl_file, f) fclose(f); return(-1); } else { - sprintf(new, NEW_FILE, acl_file); + snprintf(new, sizeof(new), NEW_FILE, acl_file); ret = unlink(new); fclose(f); return(ret); @@ -214,7 +214,7 @@ acl_commit(acl_file, f) int ret; struct stat s; - sprintf(new, NEW_FILE, acl_file); + snprintf(new, sizeof(new), NEW_FILE, acl_file); if(fflush(f) < 0 || fstat(fileno(f), &s) < 0 || s.st_nlink == 0) { @@ -484,10 +484,10 @@ acl_check(acl, principal) realm = strchr(canon, REALM_SEP); *strchr(canon, INST_SEP) = '\0'; /* Chuck the instance */ - sprintf(buf, "%s.*%s", canon, realm); + snprintf(buf, sizeof(buf), "%s.*%s", canon, realm); if(acl_exact_match(acl, buf)) return(1); - sprintf(buf, "*.*%s", realm); + snprintf(buf, sizeof(buf), "*.*%s", realm); if(acl_exact_match(acl, buf) || acl_exact_match(acl, "*.*@*")) return(1); return(0);