From: david.goulet@polymtl.ca (David Goulet)
Subject: [ltt-dev] [UST PATCH] Fix return value handling for libustcmd
Date: Tue, 7 Sep 2010 16:26:12 -0400 [thread overview]
Message-ID: <1283891172-1695-1-git-send-email-david.goulet@polymtl.ca> (raw)
Return value was not checked correctly so this was
triggering a free() on an invalid pointer causing
ustctl to fail badly.
Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
libustcmd/ustcmd.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/libustcmd/ustcmd.c b/libustcmd/ustcmd.c
index 5b4fd02..f0a6ae0 100644
--- a/libustcmd/ustcmd.c
+++ b/libustcmd/ustcmd.c
@@ -97,7 +97,7 @@ int ustcmd_set_marker_state(const char *mn, int state, pid_t pid)
}
result = ustcmd_send_cmd(cmd, pid, NULL);
- if (result) {
+ if (result != 1) {
free(cmd);
return USTCMD_ERR_GEN;
}
@@ -182,9 +182,8 @@ int ustcmd_get_subbuf_size(const char *channel, pid_t pid)
}
result = ustcmd_send_cmd(cmd, pid, &reply);
- if (result) {
+ if (result != 1) {
free(cmd);
- free(reply);
return -1;
}
@@ -214,9 +213,8 @@ int ustcmd_get_subbuf_num(const char *channel, pid_t pid)
}
result = ustcmd_send_cmd(cmd, pid, &reply);
- if (result) {
+ if (result != 1) {
free(cmd);
- free(reply);
return -1;
}
@@ -488,7 +486,6 @@ int ustcmd_get_sock_path(char **sock_path, pid_t pid)
result = ustcmd_send_cmd(cmd, pid, &reply);
if (result != 1) {
free(cmd);
- free(reply);
return USTCMD_ERR_GEN;
}
@@ -516,7 +513,7 @@ int ustcmd_force_switch(pid_t pid)
* @param pid Targeted PID
* @param reply Pointer to string to be filled with a reply string (must
* be NULL if no reply is needed for the given command).
- * @return -1 if successful, 0 on EOT, 1 on success
+ * @return -1 if not successful, 0 on EOT, 1 on success
*/
int ustcmd_send_cmd(const char *cmd, const pid_t pid, char **reply)
--
1.7.2.2
next reply other threads:[~2010-09-07 20:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-07 20:26 David Goulet [this message]
2010-09-07 20:56 ` Mathieu Desnoyers
2010-09-07 22:13 ` David Goulet
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=1283891172-1695-1-git-send-email-david.goulet@polymtl.ca \
--to=david.goulet@polymtl.ca \
/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