Пример #1
0
INT CImplVulfix::ExpressScanSystem()
{
	// Not use IUpdate 
	HRESULT hr = Scan( VULSCAN_EXPRESS_SCAN );
	if(FAILED(hr))
		return 0;
	
	// check date 
	T_Date date;
	GetLatestPackgeDate(date.nYear, date.nMonth, date.nDay);

	// 上次扫描为安全的库版本号 
	CString strLastSafePkgDate;
	ReadVulConfig(_T("VulScan"), _T("LastSafePkgDate"), strLastSafePkgDate);
	T_Date dateSafe;

	SHOWMSG(_T("PkgDate %04d-%02d-%02d \r\nLastScan.PkgDate %s"), date.nYear, date.nMonth, date.nDay, strLastSafePkgDate);
	if(!strLastSafePkgDate.IsEmpty() && ParseDateString(strLastSafePkgDate, dateSafe.nYear, dateSafe.nMonth, dateSafe.nDay) )
	{
		if(date.Compare(dateSafe.nYear, dateSafe.nMonth, dateSafe.nDay)<=0)
			return -1;
	}
	
	FILETIME ft;
	SYSTEMTIME systime={0};
	if( GetLatestInstalledKBDate(ft) && FileTimeToSystemTime(&ft, &systime) )
	{
		SHOWMSG(_T("ExpressScanSystem.DateCompare %d-%d-%d - %d-%d-%d"), date.nYear, date.nMonth, date.nDay, systime.wYear, systime.wMonth, systime.wDay);
		return date.Compare(systime.wYear, systime.wMonth, systime.wDay);
	}
	return 0;
}
Пример #2
0
/* Attempt to process an SMB file sharing URI, as described in the
 * January 8, 2007 IETF draft titled "SMB File Sharing URI Scheme",
 * as submitted by Christopher R. Hertel and the Samba Team.
 *
 * This implementation does not use the parameters which the draft
 * describes since they are not supported by the Amiga smbfs program.
 *
 * This function will return NULL in case of failure. Processing and
 * validating the individual URI components is the job of the caller,
 * we only try to parse the URI string here. Note that the parser is
 * not particularly sophisticated...
 */
struct smb_url_args *
parse_smb_url_args(const char * arg)
{
	size_t len = strlen(arg);

	size_t domain_start = 0;
	size_t domain_end = 0;
	size_t username_start = 0;
	size_t username_end = 0;
	size_t password_start = 0;
	size_t password_end = 0;
	size_t server_start = 0;
	size_t server_end = 0;
	size_t port_start = 0;
	size_t port_end = 0;
	size_t share_start = 0;
	size_t share_end = 0;
	size_t path_start = 0;
	size_t path_end = 0;
	size_t i;

	struct smb_url_args * result = NULL;
	struct smb_url_args * smb_url_args = NULL;

	ENTER();

	/* This should be an SMB url to begin with. */
	if(len <= 6 || !could_be_smb_url(arg))
	{
		SHOWMSG("not a valid SMB url");
		goto out;
	}

	/* Skip the "smb://" part. */
	arg += 6;
	len -= 6;

	smb_url_args = allocate_smb_url_args();
	if(smb_url_args == NULL)
		goto out;

	/* Try to find the optional domain name, user name
	 * and password in the URL. We look for the '@' character
	 * which separates this optional part from the
	 * server name.
	 */
	for(i = 0 ; i < len ; i++)
	{
		if(arg[i] == '@')
		{
			size_t at = i;
			size_t j;

			/* Could there be a domain name in front
			 * of the user name?
			 */
			for(j = 0 ; j < at ; j++)
			{
				if(arg[j] == ';')
				{
					domain_end = j;

					username_start = j+1;
					break;
				}
			}

			/* Try to obtain the user name and the
			 * optional password.
			 */
			for(j = username_start ; j <= at ; j++)
			{
				if(j == at || arg[j] == ':')
				{
					username_end = j;

					/* The password follows the ':'
					 * character, if there is one.
					 */
					if(j < at)
					{
						password_start = j+1;
						password_end = at;
					}

					break;
				}
			}

			/* The server name should follow the
			 * '@' character.
			 */
			server_start = at+1;

			break;
		}
	}

	/* Try to find the server name, which may be followed
	 * by a port number/service name, the share name
	 * or the parameter list.
	 */
	for(i = server_start ; i <= len ; i++)
	{
		if(i == len || arg[i] == '/' || arg[i] == ':')
		{
			server_end = i;

			if(i < len)
			{
				/* The port number/service name follow the
				 * ':' character.
				 */
				if(arg[i] == ':')
				{
					size_t j;

					port_start = i+1;

					/* Figure out how long the port number/service
					 * name text is, and pick up the start of the
					 * share name or the parameter list.
					 */
					for(j = port_start ; j <= len ; j++)
					{
						if(j == len || arg[j] == '/' || arg[j] == '?')
						{
							port_end = j;

							/* Did we find the share name? */
							if(j < len && arg[j] == '/')
								share_start = j+1;

							break;
						}
					}
				}
				/* We'll look for the share name instead.
				 * Of course, we could look for the parameter
				 * list, but the SMB URI is none too useful
				 * without the share name, so we prefer that
				 * instead.
				 */
				else
				{
					share_start = i+1;
				}
			}

			break;
		}
	}

	/* Try to find the share name, and pick up the
	 * path name or the parameter list which may
	 * follow it.
	 */
	if(share_start > 0)
	{
		for(i = share_start ; i <= len ; i++)
		{
			if(i == len || arg[i] == '/' || arg[i] == '?')
			{
				share_end = i;

				if(i < len)
				{
					/* Pick up the path name? */
					if(arg[i] == '/')
						path_start = i+1;
				}

				break;
			}
		}
	}

	/* Try to pick up the path name. */
	if(path_start > 0)
	{
		for(i = path_start ; i <= len ; i++)
		{
			if(i == len || arg[i] == '?')
			{
				path_end = i;
				break;
			}
		}
	}

	if(domain_start < domain_end)
	{
		smb_url_args->domain = copy_substring(arg, domain_start, domain_end);
		if(smb_url_args->domain == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->domain, domain_end - domain_start);

		D(("domain: '%s'", smb_url_args->domain));
	}
	else
	{
		SHOWMSG("no domain name provided");
	}

	if(username_start < username_end)
	{
		smb_url_args->username = copy_substring(arg, username_start, username_end);
		if(smb_url_args->username == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->username, username_end - username_start);

		D(("username: '******'", smb_url_args->username));
	}
	else
	{
		SHOWMSG("no user name provided");
	}

	if(password_start < password_end)
	{
		smb_url_args->password = copy_substring(arg, password_start, password_end);
		if(smb_url_args->password == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->password, password_end - password_start);

		D(("password: ..."));
	}
	else
	{
		SHOWMSG("no password provided");
	}

	if(server_start < server_end)
	{
		smb_url_args->server = copy_substring(arg, server_start, server_end);
		if(smb_url_args->server == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->server, server_end - server_start);

		D(("server: '%s'", smb_url_args->server));
	}
	else
	{
		SHOWMSG("no server name provided");
	}

	if(port_start < port_end)
	{
		smb_url_args->port = copy_substring(arg, port_start, port_end);
		if(smb_url_args->port == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->port, port_end - port_start);

		D(("port: '%s'", smb_url_args->port));
	}
	else
	{
		SHOWMSG("no port number/service name provided");
	}

	if(share_start < share_end)
	{
		smb_url_args->share = copy_substring(arg, share_start, share_end);
		if(smb_url_args->share == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->share, share_end - share_start);

		D(("share: '%s'", smb_url_args->share));
	}
	else
	{
		SHOWMSG("no share name provided");
	}

	if(path_start < path_end)
	{
		smb_url_args->path = copy_substring(arg, path_start, path_end);
		if(smb_url_args->path == NULL)
		{
			SHOWMSG("not enough memory");
			goto out;
		}

		replace_escape_sequences(smb_url_args->path, path_end - path_start);

		D(("path: '%s'", smb_url_args->path));
	}
	else
	{
		SHOWMSG("no path name provided");
	}

	result = smb_url_args;
	smb_url_args = NULL;

 out:

	if(smb_url_args != NULL)
		free_smb_url_args(smb_url_args);

	RETURN(result);
	return(result);
}