Message ID | 174042401290.1205942.5986684789242095979.stgit@frogsfrogsfrogs (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/3] xfs_scrub: fix buffer overflow in string_escape | expand |
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
diff --git a/scrub/common.c b/scrub/common.c index 6eb3c026dc5ac9..2b2d4a67bc47a2 100644 --- a/scrub/common.c +++ b/scrub/common.c @@ -320,7 +320,11 @@ string_escape( char *q; int x; - str = malloc(strlen(in) * 4); + /* + * Each non-printing byte renders as a four-byte escape sequence, so + * allocate 4x the input length, plus a byte for the null terminator. + */ + str = malloc(strlen(in) * 4 + 1); if (!str) return NULL; for (p = in, q = str; *p != '\0'; p++) {