otherstr = malloc(len); mungedhost = malloc(3*strlen(host)+1);
otherstr = smalloc(len); mungedhost = smalloc(3*strlen(host)+1);
void verify_ssh_host_key(char *host, char *keystr) {    char *otherstr, *mungedhost;    int len;    HKEY rkey;    len = 1 + strlen(keystr);    /*     * Now read a saved key in from the registry and see what it     * says.     */    otherstr = malloc(len);    mungedhost = malloc(3*strlen(host)+1);    if (!otherstr || !mungedhost)	fatalbox("Out of memory");    mungestr(host, mungedhost);    if (RegCreateKey(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",		     &rkey) != ERROR_SUCCESS) {	if (MessageBox(NULL, "PuTTY was unable to open the host key cache\n"		       "in the registry. There is thus no way to tell\n"		       "if the remote host is what you think it is.\n"		       "Connect anyway?", "PuTTY Problem",		       MB_ICONWARNING | MB_YESNO) == IDNO)	    exit(0);    } else {	DWORD readlen = len;	DWORD type;	int ret;	ret = RegQueryValueEx(rkey, mungedhost, NULL,			      &type, otherstr, &readlen);	if (ret == ERROR_MORE_DATA ||	    (ret == ERROR_SUCCESS && type == REG_SZ &&	     strcmp(otherstr, keystr))) {	    if (MessageBox(NULL,			   "This host's host key is different from the\n"			   "one cached in the registry! Someone may be\n"			   "impersonating this host for malicious reasons;\n"			   "alternatively, the host key may have changed\n"			   "due to sloppy system administration.\n"			   "Replace key in registry and connect?",			   "PuTTY: Security Warning",			   MB_ICONWARNING | MB_YESNO) == IDNO)		exit(0);	    RegSetValueEx(rkey, mungedhost, 0, REG_SZ, keystr,			  strlen(keystr)+1);	} else if (ret != ERROR_SUCCESS || type != REG_SZ) {	    if (MessageBox(NULL,			   "This host's host key is not cached in the\n"			   "registry. Do you want to add it to the cache\n"			   "and carry on connecting?",			   "PuTTY: New Host",			   MB_ICONWARNING | MB_YESNO) == IDNO)		exit(0);	    RegSetValueEx(rkey, mungedhost, 0, REG_SZ, keystr,			  strlen(keystr)+1);	}	RegCloseKey(rkey);    }}