Avoid unchecked sprintf in some more support code
authorKen Raeburn <raeburn@mit.edu>
Thu, 12 Jul 2007 23:34:04 +0000 (23:34 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 12 Jul 2007 23:34:04 +0000 (23:34 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19704 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/libpty/update_utmp.c
src/util/ss/help.c

index d2de6428f6be7c1c6ca927b304e5b63f80452cfe..8f3d6a66ca5f5831f54f5c60f237c76825fc0b35 100644 (file)
@@ -550,9 +550,9 @@ pty_update_utmp(int process_type, int pid, const char *username,
     strcpy(utmp_id, cp);
 #else
     if (len > 2 && *(cp - 1) != '/')
-      sprintf(utmp_id, "k%s", cp - 1);
+       snprintf(utmp_id, sizeof(utmp_id), "k%s", cp - 1);
     else
-      sprintf(utmp_id, "k0%s", cp);
+       snprintf(utmp_id, sizeof(utmp_id), "k0%s", cp);
 #endif
     strncpy(utx.ut_id, utmp_id, sizeof(utx.ut_id));
     /*
index 2752f40edc437ce3f8aec975e73ec64dc1fbebbb..0199397953df220816513158a84c8b71c82f9f3b 100644 (file)
@@ -38,8 +38,9 @@ void ss_help (argc, argv, sci_idx, info_ptr)
     }
     else if (argc != 2) {
        /* should do something better than this */
-       sprintf(buffer, "usage:\n\t%s [topic|command]\nor\t%s\n",
-               request_name, request_name);
+       snprintf(buffer, sizeof(buffer),
+                "usage:\n\t%s [topic|command]\nor\t%s\n",
+                request_name, request_name);
        ss_perror(sci_idx, 0, buffer);
        return;
     }