[PATCH] libmm-glib, sms-properties: fix potential NULL dereference

Dan Williams dcbw at redhat.com
Fri Aug 11 21:02:08 UTC 2017


On Fri, 2017-08-11 at 13:39 -0700, Ben Chan wrote:
> On Fri, Aug 11, 2017 at 11:32 AM, Ben Chan <benchan at chromium.org>
> wrote:
> 
> > This patch fixes a potential NULL referenece issue in
> > mm_sms_properties_get_data() where it accesses `self->priv->data-
> > >data'
> > when `self->priv->data' could be potentially NULL.
> > ---
> >  libmm-glib/mm-sms-properties.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libmm-glib/mm-sms-properties.c b/libmm-glib/mm-sms-
> > properties.c
> > index da4aa804..d66e0dab 100644
> > --- a/libmm-glib/mm-sms-properties.c
> > +++ b/libmm-glib/mm-sms-properties.c
> > @@ -157,7 +157,10 @@ mm_sms_properties_get_data (MMSmsProperties
> > *self,
> >  {
> >      g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL);
> > 
> > -    if (self->priv->data && data_len)
> > +    if (!self->priv->data)
> > 
> 
> We should probably set *data_len = 0 (if data_len is provided) in
> this case
> as well. WDYT?

Yeah, we could.  I don't think there's any real convention around this
though.  At least in this case since the function isn't returning an
error (in which case I wouldn't expect to set *data_len=0) I think it's
fine to do so.

Dan

> 
> > +        return NULL;
> > +
> > +    if (data_len)
> >          *data_len = self->priv->data->len;
> > 
> >      return self->priv->data->data;
> > --
> > 2.14.0.434.g98096fd7a8-goog
> > 
> > _______________________________________________
> > ModemManager-devel mailing list
> > ModemManager-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
> > 
> 
> _______________________________________________
> ModemManager-devel mailing list
> ModemManager-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


More information about the ModemManager-devel mailing list