Permalink
Browse files

throw exceptions if cache_location or settings_locations isn't readab…

…le/writable/executable
  • Loading branch information...
1 parent 0a6021f commit 0ba34fdb0d4d97a228671acb282fd4e798d7033b @vilhelmk committed Oct 19, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 spotify.c
View
@@ -69,6 +69,17 @@ PHP_METHOD(Spotify, __construct)
config.settings_location = INI_STR("spotify.settings_location");
config.user_agent = "libspotify-php";
+ // XXX access() is not portable
+ if (access(config.cache_location, W_OK|X_OK|R_OK) != 0) {
+ zend_throw_exception((zend_class_entry*)zend_exception_get_default(), "spotify.cache_location is not writable or readable", 0 TSRMLS_CC);
+ return;
+ }
+
+ if (access(config.settings_location, W_OK|X_OK|R_OK) != 0) {
+ zend_throw_exception((zend_class_entry*)zend_exception_get_default(), "spotify.settings_location is not writable or readable", 0 TSRMLS_CC);
+ return;
+ }
+
key_filename = Z_STRVAL_P(z_key);
fp = fopen(key_filename, "rb");

0 comments on commit 0ba34fd

Please sign in to comment.