smack-team / smack

Smack userspace
GNU Lesser General Public License v2.1
41 stars 33 forks source link

libsmack: fix potential null pointer dereference #115

Closed JanCybulski closed 9 years ago

JanCybulski commented 10 years ago

Check input pointer parameter of smack_new_label_from* functions

Signed-off-by: Jan Cybulski j.cybulski@samsung.com

rafal-krypa commented 10 years ago

I'm against such checks. If caller passes null as argument, it should crash. The rest of libsmack doesn't check function arguments for null pointers. Exactly the same behaviour is provided by several other low-level libraries, like libc.

ware commented 10 years ago

I would suggest that libsmack is a little higher level than libraries like libc. I would recommend we actually check for null pointers. If you check for it and return an error instead of just crashing, the caller has a chance to be able to do something intelligent about it. If you just null-pointer dereference, the caller can't have the opportunity to do anything intelligent or robust.

That said, I'm sure the maintainer will make an appropriate decision.

jobol commented 10 years ago

multiplying tests consumes to much power just leaving the caller be right is enough

That said, I'm sure the maintainer will make an appropriate decision.

JanCybulski commented 10 years ago

Actually: I originally had another idea: instead of just returning -1 libsmack could just return lenght of label. This might be a little helpful sometimes: when you need to know what is the length and do not need label itself.

jobol commented 10 years ago

This kind of behaviour is useful when the client allocates the buffer but it is not the case here then I'm sceptical about the real interest.

JanCybulski commented 10 years ago

Yes, I understand this, and I think, that it would be good if libsmack provided api for storing label in user buffer. Nevertheless There is no such api now, so you are absolutely right.

JanCybulski commented 9 years ago

Ok, I think there is no will of mergint this. l will close this.