| 1 | Index: ssh.c |
| 2 | =================================================================== |
| 3 | RCS file: /cvs/src/usr.bin/ssh/ssh.c,v |
| 4 | retrieving revision 1.305 |
| 5 | diff -u -p -r1.305 ssh.c |
| 6 | --- ssh.c 29 Oct 2007 06:54:50 -0000 1.305 |
| 7 | +++ ssh.c 3 Nov 2007 00:32:14 -0000 |
| 8 | @@ -1239,6 +1239,7 @@ load_public_identity_files(void) |
| 9 | #endif /* SMARTCARD */ |
| 10 | if ((pw = getpwuid(original_real_uid)) == NULL) |
| 11 | fatal("load_public_identity_files: getpwuid failed"); |
| 12 | + pw = pwcopy(pw); |
| 13 | if (gethostname(thishost, sizeof(thishost)) == -1) |
| 14 | fatal("load_public_identity_files: gethostname: %s", |
| 15 | strerror(errno)); |
| 16 | @@ -1256,6 +1257,7 @@ load_public_identity_files(void) |
| 17 | options.identity_files[i] = filename; |
| 18 | options.identity_keys[i] = public; |
| 19 | } |
| 20 | + pwfree(pw); |
| 21 | } |
| 22 | |
| 23 | static void |
| 24 | Index: misc.c |
| 25 | =================================================================== |
| 26 | RCS file: /cvs/src/usr.bin/ssh/misc.c,v |
| 27 | retrieving revision 1.65 |
| 28 | diff -u -p -r1.65 misc.c |
| 29 | --- misc.c 23 Nov 2006 01:35:11 -0000 1.65 |
| 30 | +++ misc.c 3 Nov 2007 00:32:14 -0000 |
| 31 | @@ -197,6 +197,28 @@ pwcopy(struct passwd *pw) |
| 32 | return copy; |
| 33 | } |
| 34 | |
| 35 | +void |
| 36 | +pwfree(struct passwd *pw) |
| 37 | +{ |
| 38 | +#define PW_CLEAR_FREE(f) \ |
| 39 | + do { \ |
| 40 | + if (pw->f != NULL) { \ |
| 41 | + bzero(pw->f, strlen(pw->f)); \ |
| 42 | + xfree(pw->f); \ |
| 43 | + } \ |
| 44 | + } while (0) |
| 45 | + |
| 46 | + PW_CLEAR_FREE(pw_name); |
| 47 | + PW_CLEAR_FREE(pw_passwd); |
| 48 | + PW_CLEAR_FREE(pw_gecos); |
| 49 | + PW_CLEAR_FREE(pw_class); |
| 50 | + PW_CLEAR_FREE(pw_dir); |
| 51 | + PW_CLEAR_FREE(pw_shell); |
| 52 | + bzero(pw, sizeof(*pw)); |
| 53 | + xfree(pw); |
| 54 | +#undef PW_CLEAR_FREE |
| 55 | +} |
| 56 | + |
| 57 | /* |
| 58 | * Convert ASCII string to TCP/IP port number. |
| 59 | * Port must be >0 and <=65535. |
| 60 | Index: misc.h |
| 61 | =================================================================== |
| 62 | RCS file: /cvs/src/usr.bin/ssh/misc.h,v |
| 63 | retrieving revision 1.36 |
| 64 | diff -u -p -r1.36 misc.h |
| 65 | --- misc.h 18 Aug 2006 10:27:16 -0000 1.36 |
| 66 | +++ misc.h 3 Nov 2007 00:32:14 -0000 |
| 67 | @@ -35,6 +35,7 @@ char *tohex(const void *, size_t); |
| 68 | void sanitise_stdfd(void); |
| 69 | |
| 70 | struct passwd *pwcopy(struct passwd *); |
| 71 | +void pwfree(struct passwd *); |
| 72 | |
| 73 | typedef struct arglist arglist; |
| 74 | struct arglist { |