uniba-swt / swtbahn-cli

A client-server command line interface for the SWTbahn.
GNU General Public License v3.0
7 stars 3 forks source link

Incorrect Check if Engine/Interlocker is invalid/unremovable in server / handler_upload.c #39

Closed BLuedtke closed 2 years ago

BLuedtke commented 2 years ago

File in question: server/src/handler_upload.c

Description: In the methods handler_remove_engine and handler_remove_interlocker, we want to NOT fulfill the request if the name of the object to remove is null OR the name equals the name of the default object which is supposed to be unremovable.

In handler_remove_engine, the check looks like this:
if (name == NULL && engine_is_unremovable(name)) { //not allowed, error message }
which means: If the name is null AND the name matches the name of the default object which shouldn't be removed. This should be an OR instead. Because the name of the default object is not 'null', this if condition can never evaluate to true.

The problem is pretty much the same in handler_remove_interlocker; a logical OR needs to be used instead of a logical AND.

Consequences: If this is not corrected, the default (supposedly unremovable) objects could maybe be deleted.

Fix: Switch && to ||.