Skip to contentSkip to conversation

trace-cmd: Fix segmentation fault in trace-snapshot

PATCH In review John Kacur 2 participants 2 messages Mar 21, 2017

lore
Share & tools
lore

John Kacur

author
#0 lore raw

PATCH 1/1 trace-cmd: Fix segmentation fault in trace-snapshot

To reproduce the problem:

plugin 'wakeup'
trace-cmd: Device or resource busy
Segmentation fault (core dumped)

When the user triggers a condition such as EBUSY the program should die gracefully. The problem here is simply caused by an extra conversion specifier in "die" in the write_file function

---
 trace-snapshot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
trace-snapshot.c +2 -1
index 9d3608c49563..771b065ccfa4 100644
@@ -42,7 +42,8 @@ static void write_file(const char *name, char *val)
 
 	n = write(fd, val, strlen(val));
 	if (n < 0)
-		die("failed to write '%d' to %s\n", path);
+		die("failed to write to %s\n", path);
+
 	tracecmd_put_tracing_file(path);
 	close(fd);
 }
Signature · 1 line
2.5.5
#1 lore raw
Quoted 9 lines · On Tue, 21 Mar 2017 17:11:53 +0100 John Kacur <[email protected]> wrote:

To reproduce the problem:

plugin 'wakeup'
trace-cmd: Device or resource busy
Segmentation fault (core dumped)

When the user triggers a condition such as EBUSY the program should die gracefully. The problem here is simply caused by an extra conversion specifier in "die" in the write_file function

Thanks John!

I'm currently traveling but I'll apply this when I get a chance.

-- Steve

Quoted 20 lines
---
 trace-snapshot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
trace-snapshot.c +2 -1
index 9d3608c49563..771b065ccfa4 100644
@@ -42,7 +42,8 @@ static void write_file(const char *name, char *val)
 
 	n = write(fd, val, strlen(val));
 	if (n < 0)
-		die("failed to write '%d' to %s\n", path);
+		die("failed to write to %s\n", path);
+
 	tracecmd_put_tracing_file(path);
 	close(fd);
 }