@@ -569,14 +569,19 @@ int main(int argc, char **argv)
569569 syslog (LOG_DEBUG, " mounting `%s' at mount-point `%s'" ,
570570 sparsebundle.path , sparsebundle.mountpoint );
571571
572- syslog (LOG_DEBUG, " mounting as uid=%d, with allow_other=%d and allow_root=%d" ,
573- getuid (), sparsebundle.options .allow_other , sparsebundle.options .allow_root );
572+ char *last_dot = strrchr (sparsebundle.path , ' .' );
573+ if (!last_dot || strcmp (last_dot, " .sparsebundle" ) != 0 )
574+ sparsebundle_fatal_error (" %s is not a sparse bundle (wrong extension)" ,
575+ sparsebundle.path );
574576
575577 char *plist_path;
576578 if (asprintf (&plist_path, " %s/Info.plist" , sparsebundle.path ) == -1 )
577579 sparsebundle_fatal_error (" could not resolve Info.plist path" );
578580
579581 ifstream plist_file (plist_path);
582+ if (!plist_file.is_open ())
583+ sparsebundle_fatal_error (" failed to open %s" , plist_path);
584+
580585 stringstream plist_data;
581586 plist_data << plist_file.rdbuf ();
582587
@@ -604,6 +609,12 @@ int main(int argc, char **argv)
604609 syslog (LOG_DEBUG, " bundle has band size %ju and total size %ju" ,
605610 uintmax_t (sparsebundle.band_size ), uintmax_t (sparsebundle.size ));
606611
612+ if (!sparsebundle.band_size || !sparsebundle.size )
613+ sparsebundle_fatal_error (" invalid (zero) band size or total size" );
614+
615+ syslog (LOG_DEBUG, " mounting as uid=%d, with allow_other=%d and allow_root=%d" ,
616+ getuid (), sparsebundle.options .allow_other , sparsebundle.options .allow_root );
617+
607618 struct fuse_operations sparsebundle_filesystem_operations = {};
608619 sparsebundle_filesystem_operations.getattr = sparsebundle_getattr;
609620 sparsebundle_filesystem_operations.open = sparsebundle_open;
0 commit comments