troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
621 stars 61 forks source link

Possible undefined behavior when --with-fstab=no is set #404

Closed efecanicoz-atlas closed 2 months ago

efecanicoz-atlas commented 3 months ago

When i set --with-fstab=no configure setting FINIT_FSTAB to NULL and at conf_parse_cmdline in conf.c we pass it to strdup. Looks like null strdup is expecting valid string and doesn't handle null as an argument properly.

troglobit commented 3 months ago

True, also highly untested territory. Most of the mount/fsck functions in finit.c require fstab to be != NULL, so even if we fix that instance you'd run into others a while later.

Are you trying to run Finit without it handling any fstab/mount/fsck, or is this just a general observation? It's easier for me to understand if you explain a bit about the background, where you're coming from or want to achieve.

efecanicoz-atlas commented 2 months ago

It was just an observation, i was having a look about what options we have related to fs mounting. If i understand correctly finit going to try to fetch fstab directory from kernel parameters, right ? Maybe existence checks in fs_mount_all protects the rest of the finit from having a null.

troglobit commented 2 months ago

It was just an observation, i was having a look about what options we have related to fs mounting.

OK, thanks! I'm preparing for a new release so was curious if there was something else to it.

If i understand correctly finit going to try to fetch fstab directory from kernel parameters, right ? Maybe existence checks in fs_mount_all protects the rest of the finit from having a null.

Yup, that's right. I'll have a look at the entire chain from configure to all uses in finit.c with your input. Thanks for checking back!