X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinpgnt.c;h=86998a2bb49127c90e04ce8ce75c435335a23d5f;hb=1de7240eb88fa24a8532ded116b4ec72dd213008;hp=04b58bb23a318084830889c331ffd261b46625c7;hpb=2eb952ca31aa13d1f6f429305fbb6f43a9a28c56;p=PuTTY.git diff --git a/windows/winpgnt.c b/windows/winpgnt.c index 04b58bb2..86998a2b 100644 --- a/windows/winpgnt.c +++ b/windows/winpgnt.c @@ -16,6 +16,7 @@ #include "tree234.h" #include "winsecur.h" #include "pageant.h" +#include "licence.h" #include @@ -48,7 +49,7 @@ #define APPNAME "Pageant" -extern char ver[]; +extern const char ver[]; static HWND keylist; static HWND aboutbox; @@ -125,36 +126,7 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg, { switch (msg) { case WM_INITDIALOG: - SetDlgItemText(hwnd, 1000, - "Copyright 1997-2015 Simon Tatham.\r\n\r\n" - - "Portions copyright Robert de Bath, Joris van Rantwijk, Delian " - "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas " - "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, " - "Markus Kuhn, Colin Watson, Christopher Staite, and CORE SDI S.A.\r\n\r\n" - - "Permission is hereby granted, free of charge, to any person " - "obtaining a copy of this software and associated documentation " - "files (the ""Software""), to deal in the Software without restriction, " - "including without limitation the rights to use, copy, modify, merge, " - "publish, distribute, sublicense, and/or sell copies of the Software, " - "and to permit persons to whom the Software is furnished to do so, " - "subject to the following conditions:\r\n\r\n" - - "The above copyright notice and this permission notice shall be " - "included in all copies or substantial portions of the Software.\r\n\r\n" - - "THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT " - "WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, " - "INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " - "MERCHANTABILITY, FITNESS FOR A PARTICULAR " - "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " - "COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES " - "OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " - "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN " - "CONNECTION WITH THE SOFTWARE OR THE USE OR " - "OTHER DEALINGS IN THE SOFTWARE." -); + SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n")); return 1; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -183,7 +155,7 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg, char *text = dupprintf ("Pageant\r\n\r\n%s\r\n\r\n%s", ver, - "\251 1997-2015 Simon Tatham. All rights reserved."); + "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved."); SetDlgItemText(hwnd, 1000, text); sfree(text); } @@ -329,11 +301,32 @@ void keylist_update(void) for (i = 0; NULL != (skey = pageant_nth_ssh2_key(i)); i++) { char *listentry, *p; int pos; - /* - * Replace spaces with tabs in the fingerprint prefix, for - * nice alignment in the list box, until we encounter a : - * meaning we're into the fingerprint proper. - */ + + /* + * For nice alignment in the list box, we would ideally + * want every entry to align to the tab stop settings, and + * have a column for algorithm name, one for bit count, + * one for hex fingerprint, and one for key comment. + * + * Unfortunately, some of the algorithm names are so long + * that they overflow into the bit-count field. + * Fortunately, at the moment, those are _precisely_ the + * algorithm names that don't need a bit count displayed + * anyway (because for NIST-style ECDSA the bit count is + * mentioned in the algorithm name, and for ssh-ed25519 + * there is only one possible value anyway). So we fudge + * this by simply omitting the bit count field in that + * situation. + * + * This is fragile not only in the face of further key + * types that don't follow this pattern, but also in the + * face of font metrics changes - the Windows semantics + * for list box tab stops is that \t aligns to the next + * one you haven't already exceeded, so I have to guess + * when the key type will overflow past the bit-count tab + * stop and leave out a tab character. Urgh. + */ + p = ssh2_fingerprint(skey->alg, skey->data); listentry = dupprintf("%s\t%s", p, skey->comment); sfree(p); @@ -345,6 +338,26 @@ void keylist_update(void) break; listentry[pos++] = '\t'; } + if (skey->alg != &ssh_dss && skey->alg != &ssh_rsa) { + /* + * Remove the bit-count field, which is between the + * first and second \t. + */ + int outpos; + pos = 0; + while (listentry[pos] && listentry[pos] != '\t') + pos++; + outpos = pos; + pos++; + while (listentry[pos] && listentry[pos] != '\t') + pos++; + while (1) { + if ((listentry[outpos] = listentry[pos]) == '\0') + break; + outpos++; + pos++; + } + } SendDlgItemMessage(keylist, 100, LB_ADDSTRING, 0, (LPARAM) listentry); @@ -949,7 +962,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, debug(("couldn't get default SID\n")); #endif CloseHandle(filemap); - sfree(ourself); return 0; } @@ -962,7 +974,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, rc)); #endif CloseHandle(filemap); - sfree(ourself); sfree(ourself2); return 0; } @@ -983,7 +994,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, !EqualSid(mapowner, ourself2)) { CloseHandle(filemap); LocalFree(psd); - sfree(ourself); sfree(ourself2); return 0; /* security ID mismatch! */ } @@ -991,7 +1001,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, debug(("security stuff matched\n")); #endif LocalFree(psd); - sfree(ourself); sfree(ourself2); } else { #ifdef DEBUG_IPC @@ -1165,6 +1174,23 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) } } +#if !defined UNPROTECT && !defined NO_SECURITY + /* + * Protect our process. + */ + { + char *error = NULL; + if (!setprocessacl(error)) { + char *message = dupprintf("Could not restrict process ACL: %s", + error); + MessageBox(NULL, message, "Pageant Warning", + MB_ICONWARNING | MB_OK); + sfree(message); + sfree(error); + } + } +#endif + /* * Forget any passphrase that we retained while going over * command line keyfiles.