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

Ben Chan benchan at chromium.org
Fri Aug 11 20:39:29 UTC 2017


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?


> +        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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20170811/e66c8f3d/attachment.html>


More information about the ModemManager-devel mailing list