# mqttClient-for-Legato not building

**URL:** <https://forum.legato.io/t/mqttclient-for-legato-not-building/5125>\
**Category:** Legato Application Framework\
**Created:** [April 1, 2020, 2:32pm UTC](https://forum.legato.io/t/mqttclient-for-legato-not-building/5125 "2020-04-01T14:32:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noeltaillardat](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@noeltaillardat](https://forum.legato.io/u/noeltaillardat)\
**Post date:** [April 1, 2020, 2:32pm UTC](https://forum.legato.io/t/mqttclient-for-legato-not-building/5125/1 "2020-04-01T14:32:16Z")

</div>

Hi,

I have been using the [mqttClient-for-Legato](https://github.com/nhonchu/mqttClient-for-Legato) library for a couple of days now, and I faced an error while building the legato app providing the MQTT API:

```bash
/home/xxxxxxxx/mqttClientApi/mqttClientApiComponent/mbedtls/library/x509_crt.c:1173:62: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 254 [-Werror=format-truncation=]
         mbedtls_snprintf( entry_name, sizeof entry_name, "%s/%s", path, entry->d_name );
                                                              ^~
In file included from /home/xxxxxxxx/mqttClientApi/mqttClientApiComponent/mbedtls/library/x509_crt.c:51:0:
/home/xxxxxxxx/mqttClientApi/mqttClientApiComponent/mbedtls/include/mbedtls/platform.h:184:28: note: 'snprintf' output 2 or more bytes (assuming 257) into a destination of size 255
 #define mbedtls_snprintf snprintf
/home/xxxxxxxx/mqttClientApi/mqttClientApiComponent/mbedtls/library/x509_crt.c:1173:9: note: in expansion of macro 'mbedtls_snprintf'
         mbedtls_snprintf( entry_name, sizeof entry_name, "%s/%s", path, entry->d_name );
         ^ ~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

```

which corresponds to [this part](https://github.com/nhonchu/mqttClient-for-Legato/blob/5b4c44e9f51b4593ded55ad83649db017f6d495d/mqttClientApi/mqttClientApiComponent/mbedtls/library/x509_crt.c#L1173) of the code.

The sizes indeed do not fit, comparing the `entry_name` size [here hard-coded](https://github.com/nhonchu/mqttClient-for-Legato/blob/5b4c44e9f51b4593ded55ad83649db017f6d495d/mqttClientApi/mqttClientApiComponent/mbedtls/library/x509_crt.c#L1157), and the size of `entry->d_name` from the `dirent` struct.  
As a workaround, I had to extend the size of `entry_name` up to 257.

Now, this part of the code has been updated on the official [mbedtls](https://github.com/ARMmbed/mbedtls) project (both in the latest release—2.16—and in the release used in this mqttClient-for-Legato repo—2.9) so integrating mbedtls updates should fix the issue. I have not tried yet (few details in the interface have changed with the updates, and the legato component’s `includes` should also change), and for now simply been using my workaround.

---

<div class="post-metadata">

**Author:** ![mehdiALL1](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@mehdiALL1](https://forum.legato.io/u/mehdiALL1)\
**Post date:** [July 2, 2020, 9:11am UTC](https://forum.legato.io/t/mqttclient-for-legato-not-building/5125/2 "2020-07-02T09:11:00Z")

</div>

@noeltaillardat, What you use it’s not the official mqttClient supported by LEGATO, you need to refer to: [Search · mqtt · GitHub](https://github.com/legatoproject/legato-af/search?q=mqtt&unscoped_q=mqtt)
