#include "../libvlc.h"
#include <vlc_charset.h>
#include <vlc_fs.h>
-#include "vlc_keys.h"
+#include <vlc_keys.h>
+#include <vlc_modules.h>
#include "configuration.h"
#include "modules/modules.h"
if (!errno)
{
- if ((l > INT64_C(0x7fffffffffffffff))
- || (l < INT64_C(-0x8000000000000000)))
+#if (LLONG_MAX > 0x7fffffffffffffffLL)
+ if (l > 0x7fffffffffffffffLL
+ || l < -0x8000000000000000LL)
errno = ERANGE;
+#endif
if (*end)
errno = EINVAL;
}
- return (int)l;
+ return l;
}
#undef config_LoadConfigFile
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);
if( config_PrepareDir( p_this ) )
{
msg_Err( p_this, "no configuration directory" );
- goto error;
+ return -1;
}
file = config_OpenConfigFile( p_this );
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);
* 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 */