diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-14 16:59:43 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2017-03-02 16:56:27 +0100 |
commit | 751a88f764d90422c28f59004cee78e35cf6f409 (patch) | |
tree | 84f9b33763851471231a0da1bed4ee666e7c45a7 | |
parent | e0e525fc584197ce8d1b1dbec6c921e4485f71cf (diff) | |
download | libusbg-751a88f764d90422c28f59004cee78e35cf6f409.tar.gz libusbg-751a88f764d90422c28f59004cee78e35cf6f409.tar.bz2 libusbg-751a88f764d90422c28f59004cee78e35cf6f409.zip |
libusbgx: common: Fix usbg_read_string_alloc() to read long strings correctly
Use usbg_read_string_limited() directly to avoid length limit
hidden in usbg_read_string().
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | src/usbg_common.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/usbg_common.c b/src/usbg_common.c index 10cbdc3..89949b7 100644 --- a/src/usbg_common.c +++ b/src/usbg_common.c @@ -115,6 +115,9 @@ int usbg_read_string_limited(const char *path, const char *name, if (ret == USBG_SUCCESS) { if ((p = strchr(buf, '\n')) != NULL) *p = '\0'; + else + /* Truncate bufer if needed */ + buf[len - 1] = '\0'; } else { /* Set this as empty string */ *buf = '\0'; @@ -131,7 +134,7 @@ int usbg_read_string_alloc(const char *path, const char *name, char *new_buf = NULL; int ret; - ret = usbg_read_string(path, name, file, buf); + ret = usbg_read_string_limited(path, name, file, buf, sizeof(buf)); if (ret != USBG_SUCCESS) goto out; |