From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] debugfs: Fix writing an extra zero out of bounds in igt_crc_to_string_extended()
Date: Mon, 28 Jan 2019 12:54:36 +0100 [thread overview]
Message-ID: <20190128115436.14527-1-maarten.lankhorst@linux.intel.com> (raw)
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
lib/igt_debugfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 3656c66a5674..d1fc0ff7f710 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -458,17 +458,17 @@ char *igt_crc_to_string_extended(igt_crc_t *crc, char delimiter, int crc_size)
int i;
int len = 0;
int field_width = 2 * crc_size; /* Two chars per byte. */
- char *buf = malloc((field_width+1) * crc->n_words * sizeof(char));
+ char *buf = malloc((field_width+1) * crc->n_words);
if (!buf)
return NULL;
- for (i = 0; i < crc->n_words; i++)
+ for (i = 0; i < crc->n_words - 1; i++)
len += sprintf(buf + len, "%0*x%c", field_width,
crc->crc[i], delimiter);
- /* Eat the last delimiter */
- buf[len - 1] = '\0';
+ sprintf(buf + len, "%0*x", field_width, crc->crc[i]);
+
return buf;
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-01-28 11:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 11:54 Maarten Lankhorst [this message]
2019-01-28 12:24 ` [igt-dev] [PATCH i-g-t] debugfs: Fix writing an extra zero out of bounds in igt_crc_to_string_extended() Jani Nikula
2019-01-31 16:14 ` Maarten Lankhorst
2019-02-01 9:38 ` Jani Nikula
2019-02-01 9:55 ` Maarten Lankhorst
2019-01-28 13:18 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-01-28 16:30 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190128115436.14527-1-maarten.lankhorst@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox