g_timeout_source_new_seconds().
CONFNAME_APPINFO_POLLINTERVAL,
APP_INFO_POLL_INTERVAL);
- if (pollInterval < 0) {
+ if (pollInterval < 0 || pollInterval > (G_MAXINT / 1000)) {
g_warning("%s: Invalid poll interval %d. Using default %us.\n",
__FUNCTION__, pollInterval, APP_INFO_POLL_INTERVAL);
pollInterval = APP_INFO_POLL_INTERVAL;
CONFNAME_CONTAINERINFO_POLLINTERVAL,
CONTAINERINFO_DEFAULT_POLL_INTERVAL);
- if (pollInterval < 0) {
+ if (pollInterval < 0 || pollInterval > (G_MAXINT / 1000)) {
g_warning("%s: Invalid poll interval %d. Using default %us.\n",
__FUNCTION__, pollInterval,
CONTAINERINFO_DEFAULT_POLL_INTERVAL);
gint pollInterval = 0;
if (enable) {
- pollInterval = defInterval * 1000;
-
/*
* Check the config registry for custom poll interval,
* converting from seconds to milliseconds.
*/
- if (g_key_file_has_key(ctx->config, CONFGROUPNAME_GUESTINFO,
- cfgKey, NULL)) {
- GError *gError = NULL;
-
- pollInterval = g_key_file_get_integer(ctx->config,
- CONFGROUPNAME_GUESTINFO,
- cfgKey, &gError);
- pollInterval *= 1000;
-
- if (pollInterval < 0 || gError) {
- g_warning("Invalid %s.%s value. Using default %us.\n",
- CONFGROUPNAME_GUESTINFO, cfgKey, defInterval);
- pollInterval = defInterval * 1000;
- }
-
- g_clear_error(&gError);
+ pollInterval = VMTools_ConfigGetInteger(ctx->config,
+ CONFGROUPNAME_GUESTINFO,
+ cfgKey, defInterval);
+ if (pollInterval < 0 || pollInterval > (G_MAXINT / 1000)) {
+ g_warning("Invalid %s.%s value. Using default %us.\n",
+ CONFGROUPNAME_GUESTINFO, cfgKey, defInterval);
+ pollInterval = defInterval;
}
+
+ pollInterval *= 1000;
}
if (*timeoutSource != NULL) {
clientRecvTimeout = GUESTSTORE_CONFIG_GET_INT("clientRecvTimeout",
DEFAULT_CLIENT_RECV_TIMEOUT);
- if (clientRecvTimeout <= 0) {
+ if (clientRecvTimeout <= 0 || clientRecvTimeout > (G_MAXINT / 1000)) {
g_warning("Invalid clientRecvTimeout (%d); Using default (%d).\n",
clientRecvTimeout, DEFAULT_CLIENT_RECV_TIMEOUT);
clientRecvTimeout = DEFAULT_CLIENT_RECV_TIMEOUT;
theVmxConn->connTimeout = GUESTSTORE_CONFIG_GET_INT("connTimeout",
GUESTSTORE_DEFAULT_CONN_TIMEOUT);
- if (theVmxConn->connTimeout <= 0) {
+ if (theVmxConn->connTimeout <= 0 ||
+ theVmxConn->connTimeout > (G_MAXINT / 1000)) {
g_warning("Invalid connTimeout (%d); Using default (%d).\n",
theVmxConn->connTimeout, GUESTSTORE_DEFAULT_CONN_TIMEOUT);
theVmxConn->connTimeout = GUESTSTORE_DEFAULT_CONN_TIMEOUT;
VmBackupEnableCompleteWait(void);
+/**
+ * Returns the configured timeout value.
+ *
+ * @param[in] config Config file to read from.
+ * @param[in] defValue Default value if the timeout key is not found or error.
+ *
+ * @return value of the timeout key if read successfully,
+ * defValue otherwise.
+ */
+
+static gint
+VmBackupGetTimeout(GKeyFile *config,
+ const gint defValue)
+{
+ gint timeout = VMBACKUP_CONFIG_GET_INT(config, "timeout", defValue);
+ if (timeout < 0 || timeout > (G_MAXINT / 1000)) {
+ g_warning("Invalid timeout %d. Using default %us.",
+ timeout, defValue);
+ timeout = defValue;
+ }
+
+ return timeout;
+}
+
+
/**
* Returns a string representation of the given state machine state.
*
* See bug 506106.
*/
if (gBackupState->timeout == 0) {
- gBackupState->timeout = VMBACKUP_CONFIG_GET_INT(ctx->config, "timeout",
- GUEST_QUIESCE_DEFAULT_TIMEOUT_IN_SEC);
+ gBackupState->timeout = VmBackupGetTimeout(ctx->config,
+ GUEST_QUIESCE_DEFAULT_TIMEOUT_IN_SEC);
}
/* Treat "0" as no timeout. */
gBackupState->scriptArg = VMBACKUP_CONFIG_GET_STR(ctx->config,
"scriptArg",
NULL);
- gBackupState->timeout = VMBACKUP_CONFIG_GET_INT(ctx->config,
- "timeout", 0);
+ gBackupState->timeout = VmBackupGetTimeout(ctx->config, 0);
gBackupState->vssUseDefault = VMBACKUP_CONFIG_GET_BOOL(ctx->config,
"vssUseDefault",
TRUE);