Skip to contentSkip to conversation

Fix: relayd: handling of lttng_read errors >= 0

PATCH Jérémie Galarneau 1 participant 1 message Apr 25, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Merged in master, stable-2.11, stable-2.10, and stable-2.9.

Thanks!
Jérémie

Quoted 31 lines · Mathieu Desnoyers

errno is only set when lttng_read returns a negative value. Else, we need to print a ERR() statement rather than use PERROR().

---
 src/common/index/index.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/common/index/index.c +5 -1
index 12d54e00..9bfb56fa 100644
@@ -171,10 +171,14 @@ int lttng_index_file_read(const struct lttng_index_file *index_file,
 	}
 
 	ret = lttng_read(fd, element, len);
-	if (ret < len) {
+	if (ret < 0) {
 		PERROR("read index file");
 		goto error;
 	}
+	if (ret < len) {
+		ERR("lttng_read expected %zu, returned %zd", len, ret);
+		goto error;
+	}
 	return 0;
 
 error:
Signature · 1 line
2.17.1