Diff between 9db45f056b98e84730e2353018d60824c16d9cc4 and fa7c60eb0c450a5b649810dc99bfbe1dd6f0ced5

Changed Files

File Additions Deletions Status
tools/hciattach.c +6 -0 modified

Full Patch

diff --git a/tools/hciattach.c b/tools/hciattach.c
index 4dc5be5..59a76a7 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -1358,6 +1358,12 @@ int main(int argc, char *argv[])
 			dev[0] = 0;
 			if (!strchr(opt, '/'))
 				strcpy(dev, "/dev/");
+
+			if (strlen(opt) > PATH_MAX - (strlen(dev) + 1)) {
+				fprintf(stderr, "Invalid serial device\n");
+				exit(1);
+			}
+
 			strcat(dev, opt);
 			break;