]> git.sesse.net Git - vlc/blobdiff - src/config/file.c
SaveConfigFile: correctly an error on I/O failure
[vlc] / src / config / file.c
index 71a02df8e672d25313cdd224d13f7e8ebbc6db97..0d3f6b6afb06553ca3bea140be53db47127c36f3 100644 (file)
@@ -274,6 +274,8 @@ int config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
                 case CONFIG_ITEM_INTEGER:
                 {
                     int64_t l = strtoi (psz_option_value);
+                    if ((l > p_item->max.i) || (l < p_item->min.i))
+                        errno = ERANGE;
                     if (errno)
                         msg_Warn (p_this, "Integer value (%s) for %s: %m",
                                   psz_option_value, psz_option_name);
@@ -435,7 +437,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     if( config_PrepareDir( p_this ) )
     {
         msg_Err( p_this, "no configuration directory" );
-        goto error;
+        return -1;
     }
 
     file = config_OpenConfigFile( p_this );
@@ -555,6 +557,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     file = fdopen (fd, "wt");
     if (file == NULL)
     {
+        msg_Err (p_this, "cannot create configuration file: %m");
         vlc_rwlock_unlock (&config_lock);
         close (fd);
         vlc_mutex_unlock (&lock);
@@ -702,6 +705,14 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
      * Flush to disk and replace atomically
      */
     fflush (file); /* Flush from run-time */
+    if (ferror (file))
+    {
+        vlc_unlink (temporary);
+        vlc_mutex_unlock (&lock);
+        msg_Err (p_this, "cannot write configuration file");
+        clearerr (file);
+        goto error;
+    }
 #ifndef WIN32
 #ifdef __APPLE__
     fsync (fd); /* Flush from OS */