Type safety for redirection tags 57/256757/2
authorMichal Bloch <m.bloch@samsung.com>
Mon, 12 Apr 2021 10:22:39 +0000 (12:22 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 12 Apr 2021 13:29:39 +0000 (15:29 +0200)
This was supposed to be self-documenting but it's fairly obvious that
the extra byte is for the terminator and I'm very worried about weird
things that can happen to the char (int promotions or something).

Change-Id: Ib33404db86055fb1840f5942e9740cbf6199d7c3
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/log-redirect-stdout/internal.c

index 81ba6c9..b41a413 100644 (file)
@@ -71,7 +71,7 @@ static int apply_android_logger_ioctl(int fd, const char *tag, log_priority prio
 
        strncpy(tag_info.tag, tag, sizeof tag_info.tag);
        tag_info.tag[sizeof tag_info.tag - 1] = '\0';
-       tag_info.len = strlen(tag_info.tag) + sizeof '\0';
+       tag_info.len = strlen(tag_info.tag) + 1;
 
        int r = ioctl(fd, LOGGER_SET_TAG, &tag_info);
        if (r < 0)