New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow invalid project files! #2523

Merged
merged 1 commit into from Sep 5, 2016

Conversation

Projects
None yet
5 participants
@zonkmachine
Member

zonkmachine commented Jan 28, 2016

The renderer hangs bad if you give it something that isn't an LMMS project as argument.


Loading project...
Done
|-                                 |      0%   \   <---infinite hang here!

This fix tests that the given file is really a file ( not a directory ). It also tests for a valid LMMS project suffix.

~/builds/lmms/build$ ./lmms -r ../build
The file ../build does not exist!

You can test specifically for if the argument is a directory and report accordingly but that would be over doing it a bit I think.

~/builds/lmms/build$ ./lmms -r ../build/lmmscon
The file ../build/lmmscon does not exist!
~/builds/lmms/build$ ./lmms -r ../build/lmmsconfig.h 
../build/lmmsconfig.h is not an LMMS project fil

I finally moved the line Engine::init( true ); to after the tests as it just felt like a better place.

@zonkmachine zonkmachine added the bug label Jan 28, 2016

@zonkmachine zonkmachine added this to the 1.2.0 milestone Jan 28, 2016

@zonkmachine zonkmachine changed the title from Don't allow crap as render argument! to Don't allow invalid arguments to the renderer! Jan 28, 2016

@tresf

This comment has been minimized.

Show comment
Hide comment
@tresf

tresf Jan 28, 2016

Member

Looks good. 👍 I'll leave time for comments. One thought was the posiblity of loading a non-mmp or non-mmpz file, but loadFile only takes projects, so that's for another time. 👍

Member

tresf commented Jan 28, 2016

Looks good. 👍 I'll leave time for comments. One thought was the posiblity of loading a non-mmp or non-mmpz file, but loadFile only takes projects, so that's for another time. 👍

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Jan 28, 2016

Member

One thought was the posiblity of loading a non-mmp or non-mmpz file,

Yes, I was going to ask about it.
I'm currently trying to move the whole file test to here. Right after fileToLoad is assigned a file.
We're currently treating file arguments for render and load differently and this should fix it. It works but I haven't tested it thoroughly. It probably makes the larger part of #2524 redundant

Member

zonkmachine commented Jan 28, 2016

One thought was the posiblity of loading a non-mmp or non-mmpz file,

Yes, I was going to ask about it.
I'm currently trying to move the whole file test to here. Right after fileToLoad is assigned a file.
We're currently treating file arguments for render and load differently and this should fix it. It works but I haven't tested it thoroughly. It probably makes the larger part of #2524 redundant

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Jan 29, 2016

Member

In the last version it still tests for an empty fileToLoad if you choose --import and halts with a
The file does not exist!

Member

zonkmachine commented Jan 29, 2016

In the last version it still tests for an empty fileToLoad if you choose --import and halts with a
The file does not exist!

@zonkmachine zonkmachine changed the title from Don't allow invalid arguments to the renderer! to Don't allow invalid project file arguments! Jan 29, 2016

@zonkmachine zonkmachine changed the title from Don't allow invalid project file arguments! to Don't allow invalid project files! Jan 29, 2016

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Jan 29, 2016

Member

importsuffixes

Same checks for files to import.

Member

zonkmachine commented Jan 29, 2016

importsuffixes

Same checks for files to import.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Jan 29, 2016

Member

One thought was the posiblity of loading a non-mmp or non-mmpz file

An mpt file?

Member

zonkmachine commented Jan 29, 2016

One thought was the posiblity of loading a non-mmp or non-mmpz file

An mpt file?

@softrabbit

This comment has been minimized.

Show comment
Hide comment
@softrabbit

softrabbit Jan 30, 2016

Member

An mpt file?

Any valid LMMS project file that happens to be named differently from what's expected? If I explicitly tell LMMS to load a file called "myproject.mmpx" or whatever, I expect it to at least try and not reject the file until it's at least opened the file and tried parsing it.

Member

softrabbit commented Jan 30, 2016

An mpt file?

Any valid LMMS project file that happens to be named differently from what's expected? If I explicitly tell LMMS to load a file called "myproject.mmpx" or whatever, I expect it to at least try and not reject the file until it's at least opened the file and tried parsing it.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Feb 7, 2016

Member

Any valid LMMS project file that happens to be named differently from what's expected? If I explicitly tell LMMS to load a file called "myproject.mmpx" or whatever, I expect it to at least try and not reject the file until it's at least opened the file and tried parsing it.

OK. Right now if you try and save a project file with another suffix than .mmp or .mmpz, it will stick a new suffix after the one you opted for. In your case with myproject.mmpx you will get myproject.mmpx.mmpz so on my Ubuntu/Mint I have to go back and change suffix manually and then myproject.mmpx will open as you expect it. Either as a command line argument or from the gui.

Edit: Only files ending mmp/mmpz will show up in the file open dialogue so other valid projects will have to be loaded from the command line.

Member

zonkmachine commented Feb 7, 2016

Any valid LMMS project file that happens to be named differently from what's expected? If I explicitly tell LMMS to load a file called "myproject.mmpx" or whatever, I expect it to at least try and not reject the file until it's at least opened the file and tried parsing it.

OK. Right now if you try and save a project file with another suffix than .mmp or .mmpz, it will stick a new suffix after the one you opted for. In your case with myproject.mmpx you will get myproject.mmpx.mmpz so on my Ubuntu/Mint I have to go back and change suffix manually and then myproject.mmpx will open as you expect it. Either as a command line argument or from the gui.

Edit: Only files ending mmp/mmpz will show up in the file open dialogue so other valid projects will have to be loaded from the command line.

Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine May 5, 2016

Member

Conflicts resolved.

Member

zonkmachine commented May 5, 2016

Conflicts resolved.

@Umcaruje

This comment has been minimized.

Show comment
Hide comment
@Umcaruje

Umcaruje Jul 8, 2016

Member

@zonkmachine is there any more work needed to be done here, or it could be tested and merged?

Member

Umcaruje commented Jul 8, 2016

@zonkmachine is there any more work needed to be done here, or it could be tested and merged?

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Jul 8, 2016

Member

Yes, mad sorry about the slow response here. Short on time. I'll look into it as soon as I possibly can.

Member

zonkmachine commented Jul 8, 2016

Yes, mad sorry about the slow response here. Short on time. I'll look into it as soon as I possibly can.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Jul 10, 2016

Member

OK. Trying to finish this one now.

Member

zonkmachine commented Jul 10, 2016

OK. Trying to finish this one now.

Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
@jasp00

This comment has been minimized.

Show comment
Hide comment
@jasp00

jasp00 Jul 21, 2016

Member

Current fix is incomplete. Input file could be an empty file, the empty template, a broken project or a different XML file. I do not think these new checks are necessary. The check for empty projects on export should be enough.

Member

jasp00 commented Jul 21, 2016

Current fix is incomplete. Input file could be an empty file, the empty template, a broken project or a different XML file. I do not think these new checks are necessary. The check for empty projects on export should be enough.

@jasp00

This comment has been minimized.

Show comment
Hide comment
@jasp00

jasp00 Jul 21, 2016

Member

I do not think these new checks are necessary.

I mean checking the extension, if the input does not exists, etc.

Member

jasp00 commented Jul 21, 2016

I do not think these new checks are necessary.

I mean checking the extension, if the input does not exists, etc.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Aug 9, 2016

Member

Right, back on this...

Input file could be an empty file,

Hm, missed that. Poking around with it right now...

the empty template

...Will open correctly.

a broken project

A file that is empty or a broken project will be passed to LMMS who will fail to open it and report on it.

emptyproject

It will then open an empty project with the title of the project you tried to open.

Member

zonkmachine commented Aug 9, 2016

Right, back on this...

Input file could be an empty file,

Hm, missed that. Poking around with it right now...

the empty template

...Will open correctly.

a broken project

A file that is empty or a broken project will be passed to LMMS who will fail to open it and report on it.

emptyproject

It will then open an empty project with the title of the project you tried to open.

@jasp00

This comment has been minimized.

Show comment
Hide comment
@jasp00

jasp00 Aug 9, 2016

Member

I mean that rendering those invalid projects (empty file, empty template, etc.) with lmms -r causes the infinite hang.

Member

jasp00 commented Aug 9, 2016

I mean that rendering those invalid projects (empty file, empty template, etc.) with lmms -r causes the infinite hang.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Aug 9, 2016

Member

Right. In the case of an empty file the latest commit proposed a fix and it's working. An empty template however, I think goes a bit beyond this PR. Shouldn't it rather be catched by the renderer?

Member

zonkmachine commented Aug 9, 2016

Right. In the case of an empty file the latest commit proposed a fix and it's working. An empty template however, I think goes a bit beyond this PR. Shouldn't it rather be catched by the renderer?

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Aug 11, 2016

Member

When exporting from the gui lmms ran TrackContainer::isEmpty() so I added this test in main.


$ ./lmms --rendertracks empty.mmpz
Notice: could not set realtime priority.
VST sync support disabled in your configuration
Loading project...
The project empty.mmpz is empty, aborting!

Member

zonkmachine commented Aug 11, 2016

When exporting from the gui lmms ran TrackContainer::isEmpty() so I added this test in main.


$ ./lmms --rendertracks empty.mmpz
Notice: could not set realtime priority.
VST sync support disabled in your configuration
Loading project...
The project empty.mmpz is empty, aborting!

Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
Show outdated Hide outdated src/core/main.cpp
{
printf("The project %s is empty, aborting!\n", fileToLoad.toUtf8().constData() );
exit( EXIT_FAILURE );
}

This comment has been minimized.

@zonkmachine

zonkmachine Sep 1, 2016

Member

Is exit() even a good way to terminate the application at this point?

@zonkmachine

zonkmachine Sep 1, 2016

Member

Is exit() even a good way to terminate the application at this point?

This comment has been minimized.

@jasp00

jasp00 Sep 4, 2016

Member

You may omit exit() and avoid the export, so an upgraded .lmmsrc.xml can be written, but exit() (or return) is not a bad way.

@jasp00

jasp00 Sep 4, 2016

Member

You may omit exit() and avoid the export, so an upgraded .lmmsrc.xml can be written, but exit() (or return) is not a bad way.

This comment has been minimized.

@zonkmachine

zonkmachine Sep 5, 2016

Member

oK. I just skimmed past some comment on the net that exit() could be a problem with multi threaded applications. I'm happy with .lmmsrc.xml not being written so we keep failing loads from appearing in the recently opened projects list.

@zonkmachine

zonkmachine Sep 5, 2016

Member

oK. I just skimmed past some comment on the net that exit() could be a problem with multi threaded applications. I'm happy with .lmmsrc.xml not being written so we keep failing loads from appearing in the recently opened projects list.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Sep 2, 2016

Member

lmms used to load default.mmp on failing to load a project but this was broken in commit: 2c7036e#diff-1c0d925f7437a8e3a837c0a991b4cf34

I'll try and look into the original issue (Edit: #781) behind that PR

Edit2: Fix for this in #3013

Member

zonkmachine commented Sep 2, 2016

lmms used to load default.mmp on failing to load a project but this was broken in commit: 2c7036e#diff-1c0d925f7437a8e3a837c0a991b4cf34

I'll try and look into the original issue (Edit: #781) behind that PR

Edit2: Fix for this in #3013

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Sep 2, 2016

Member

It's better to not inflate this PR. The regression in Song.cpp is not directly related to these fixes so I'll treat them separately.

Rebased and squashed! 🚜

Member

zonkmachine commented Sep 2, 2016

It's better to not inflate this PR. The regression in Song.cpp is not directly related to these fixes so I'll treat them separately.

Rebased and squashed! 🚜

@jasp00

This comment has been minimized.

Show comment
Hide comment
@jasp00

jasp00 Sep 4, 2016

Member

This request may be merged.

Member

jasp00 commented Sep 4, 2016

This request may be merged.

@zonkmachine zonkmachine merged commit a53fd26 into LMMS:master Sep 5, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Sep 5, 2016

Member

🚜

Member

zonkmachine commented Sep 5, 2016

🚜

@zonkmachine zonkmachine deleted the zonkmachine:directoryargument branch Sep 5, 2016

sambler pushed a commit to sambler/lmms that referenced this pull request Sep 19, 2016

sambler sambler
Merge branch 'master' into jackmidi
* master: (213 commits)
  Update Pattern and AutomationPattern length (#3037)
  Refresh i18n strings
  Hint text update
  Drop notes with length zero (#3031)
  Background tweak
  Background
  Update Flanger
  Exclude .ts files from the Github linguist
  Redesign Multitap echo (#3008)
  Update i18n source strings
  Extended arpeggiator functions (#2130)
  Fix sample track playback in BB tracks (#3023)
  Sort plug-in embedded resources (#3014)
  Implement version major.minor.release-stage.build (#3011)
  Fix regressions on loading broken projects (#3013)
  Improved file input validation. (#2523)
  Fix sample track view in BB editor (#3002)
  Request change in model when dropping a track (#3000)
  Add LocklessAllocator and use it in LocklessList (#2998)
  Drop forceStep in AutomatableModel (#3010)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment