open-power / petitboot

GNU General Public License v2.0
212 stars 56 forks source link

udev: check idpath for nullptr before calling strcmp #96

Closed julianwi closed 1 year ago

julianwi commented 1 year ago

While trying to package petitboot for postmarketos, I experienced segafults in udev.c:191. Seems that udev can return null for the ID_PATH property in some cases. This should be handled properly instead of calling strcmp on a null pointer.

jk-ozlabs commented 1 year ago

We should definitely protect against this, but just replacing this with an empty string seems like we're papering-over the problem here. Perhaps we should reject devices with no ID_PATH? What device are you seeing this with?

julianwi commented 1 year ago

Actually none of my disks and partitions has the ID_PATH property set. So simply rejecting them is not a good solution

jk-ozlabs commented 1 year ago

OK, makes sense. The ID_PATH (and dev->id_path) aren't as widely-used as I'd thought.

@LuluTHSu you added the ID_PATH checks here; any thoughts on skipping the duplicate check if it's not populated?

jk-ozlabs commented 1 year ago

@LuluTHSu ping? Let me know soon if you have any objections here.

jk-ozlabs commented 1 year ago

@julianwi mind adding a signed-off-by for this?

julianwi commented 1 year ago

added signoff