From bcdca5324361d077008be0dbecc94a7134abe663 Mon Sep 17 00:00:00 2001 From: millert Date: Sun, 15 Sep 1996 23:27:09 +0000 Subject: [PATCH] more sprintf -> snprintf paranoia --- kerberosIV/compile_et/error_table.y | 6 +++--- kerberosIV/ext_srvtab/ext_srvtab.c | 4 ++-- kerberosIV/kadmin/kadmin.c | 14 +++++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/kerberosIV/compile_et/error_table.y b/kerberosIV/compile_et/error_table.y index 11ddd22c169..2bb86fd0d50 100644 --- a/kerberosIV/compile_et/error_table.y +++ b/kerberosIV/compile_et/error_table.y @@ -1,5 +1,5 @@ %{ -/* $Id: error_table.y,v 1.1.1.1 1995/12/14 06:52:49 tholo Exp $ */ +/* $Id: error_table.y,v 1.2 1996/09/15 23:27:09 millert Exp $ */ /*- * Copyright 1987, 1988 by the Student Information Processing Board @@ -101,7 +101,7 @@ description : QUOTED_STRING #ifndef lint static char const rcsid_error_table_y[] = - "$Id: error_table.y,v 1.1.1.1 1995/12/14 06:52:49 tholo Exp $"; + "$Id: error_table.y,v 1.2 1996/09/15 23:27:09 millert Exp $"; #endif #include "et_lex.lex.c" @@ -122,7 +122,7 @@ gensym(x) } symbol = (char *)malloc(32 * sizeof(char)); gensym_n++; - sprintf(symbol, "et%ld", gensym_n); + snprintf(symbol, 32 * sizeof(char), "et%ld", gensym_n); return(symbol); } diff --git a/kerberosIV/ext_srvtab/ext_srvtab.c b/kerberosIV/ext_srvtab/ext_srvtab.c index 13a84125941..62e74ca21e8 100644 --- a/kerberosIV/ext_srvtab/ext_srvtab.c +++ b/kerberosIV/ext_srvtab/ext_srvtab.c @@ -1,4 +1,4 @@ -/* $Id: ext_srvtab.c,v 1.1.1.1 1995/12/14 06:52:41 tholo Exp $ */ +/* $Id: ext_srvtab.c,v 1.2 1996/09/15 23:28:08 millert Exp $ */ /*- * Copyright 1987, 1988 by the Student Information Processing Board @@ -124,7 +124,7 @@ main(int argc, char **argv) for (arg = 1; arg < argc; arg++) { if (argv[arg][0] == '-') continue; - sprintf(fname, "%s-new-srvtab", argv[arg]); + snprintf(fname, sizeof(fname), "%s-new-srvtab", argv[arg]); if ((fout = fopen(fname, "w")) == NULL) { fprintf(stderr, "Couldn't create file '%s'.\n", fname); fopen_errs++; diff --git a/kerberosIV/kadmin/kadmin.c b/kerberosIV/kadmin/kadmin.c index 2cb575103c3..9de5accf798 100644 --- a/kerberosIV/kadmin/kadmin.c +++ b/kerberosIV/kadmin/kadmin.c @@ -1,4 +1,4 @@ -/* $Id: kadmin.c,v 1.2 1995/12/14 08:43:44 tholo Exp $ */ +/* $Id: kadmin.c,v 1.3 1996/09/15 23:30:52 millert Exp $ */ /* * Copyright (C) 1989 by the Massachusetts Institute of Technology @@ -362,7 +362,8 @@ main(int argc, char **argv) ss_perror(sci_idx, code, "creating invocation"); exit(1); } - (void) sprintf(tktstring, "/tmp/tkt_adm_%d",(int)getpid()); + (void) snprintf(tktstring, sizeof(tktstring), "/tmp/tkt_adm_%d", + (int)getpid()); krb_set_tkt_string(tktstring); do_init(argc, argv); @@ -435,7 +436,8 @@ change_password(int argc, char **argv) return; /* get the new password */ - (void) sprintf(pw_prompt, "New password for %s:", argv[1]); + (void) snprintf(pw_prompt, sizeof(pw_prompt), "New password for %s:", + argv[1]); if (get_password(&new.key_low, &new.key_high, pw_prompt, SWAP) == GOOD_PW) { @@ -474,7 +476,8 @@ change_admin_password(int argc, char **argv) if (get_admin_password() != GOOD_PW) return; - (void) sprintf(prompt_pw, "New password for %s.admin:",myname); + (void) snprintf(prompt_pw, sizeof(prompt_pw), "New password for %s.admin:", + myname); if (get_password(&low, &high, prompt_pw, DONTSWAP) == GOOD_PW) { bcopy((char *)&low,(char *) newkey,4); bcopy((char *)&high, (char *)(((int32_t *) newkey) + 1),4); @@ -524,7 +527,8 @@ add_new_key(int argc, char **argv) get_expdate(&new); /* get the new password */ - (void) sprintf(pw_prompt, "Password for %s:", argv[1]); + (void) snprintf(pw_prompt, sizeof(pw_prompt), "Password for %s:", + argv[1]); if (get_password(&new.key_low, &new.key_high, pw_prompt, SWAP) == GOOD_PW) { -- 2.20.1