]> andersk Git - openssh.git/blobdiff - ssh-agent.c
- (stevesk) OpenSSH CVS update:
[openssh.git] / ssh-agent.c
index 9f61aec3b64559044bd2eb132e8dd54cfda3b84f..821ee26f43220bf7bfa53d0f685134d2019e4d91 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ssh-agent.c,v 1.39 2000/11/12 19:50:38 markus Exp $   */
+/*     $OpenBSD: ssh-agent.c,v 1.41 2000/11/30 18:33:05 markus Exp $   */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -37,7 +37,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.39 2000/11/12 19:50:38 markus Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.41 2000/11/30 18:33:05 markus Exp $");
 
 #include "ssh.h"
 #include "rsa.h"
@@ -93,9 +93,9 @@ char socket_dir[1024];
 
 #ifdef HAVE___PROGNAME
 extern char *__progname;
-#else /* HAVE___PROGNAME */
-static const char *__progname = "ssh-agent";
-#endif /* HAVE___PROGNAME */
+#else
+char *__progname;
+#endif
 
 void
 idtab_init(void)
@@ -308,8 +308,9 @@ process_remove_identity(SocketEntry *e, int version)
                        /*
                         * We have this key.  Free the old key.  Since we
                         * don\'t want to leave empty slots in the middle of
-                        * the array, we actually free the key there and copy
-                        * data from the last entry.
+                        * the array, we actually free the key there and move
+                        * all the entries between the empty slot and the end
+                        * of the array.
                         */
                        Idtab *tab = idtab_lookup(version);
                        key_free(tab->identities[idx].key);
@@ -318,8 +319,13 @@ process_remove_identity(SocketEntry *e, int version)
                                fatal("process_remove_identity: "
                                    "internal error: tab->nentries %d",
                                    tab->nentries);
-                       if (idx != tab->nentries - 1)
-                               tab->identities[idx] = tab->identities[tab->nentries - 1];
+                       if (idx != tab->nentries - 1) {
+                               int i;
+                               for (i = idx; i < tab->nentries - 1; i++)
+                                       tab->identities[i] = tab->identities[i+1];
+                       }
+                       tab->identities[tab->nentries - 1].key = NULL;
+                       tab->identities[tab->nentries - 1].comment = NULL;
                        tab->nentries--;
                        success = 1;
                }
@@ -668,10 +674,12 @@ main(int ac, char **av)
        fd_set readset, writeset;
        int sock, c_flag = 0, k_flag = 0, s_flag = 0, ch;
        struct sockaddr_un sunaddr;
+       struct rlimit rlim;
        pid_t pid;
        char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
        extern int optind;
        
+       __progname = get_progname(av[0]);
        init_rng();
        
 #ifdef __GNU_LIBRARY__
@@ -797,6 +805,12 @@ main(int ac, char **av)
        close(1);
        close(2);
 
+       /* deny core dumps, since memory contains unencrypted private keys */
+       rlim.rlim_cur = rlim.rlim_max = 0;
+       if (setrlimit(RLIMIT_CORE, &rlim) < 0) {
+               perror("setrlimit rlimit_core failed");
+               cleanup_exit(1);
+       }
        if (setsid() == -1) {
                perror("setsid");
                cleanup_exit(1);
This page took 0.229331 seconds and 4 git commands to generate.