<div dir="ltr">Merged in master, stable-2.7, stable-2.6 and stable-2.5. Thanks!<div><br></div><div>Jérémie</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 25, 2015 at 3:55 AM, Partha Pratim Mukherjee <span dir="ltr"><<a href="mailto:ppm.floss@gmail.com" target="_blank">ppm.floss@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">set session does not check the existence of a session before setting<br>
it as the current session. Fix it so that it gives error for<br>
not-existent session.<br>
<br>
Fixes: #885<br>
<br>
Signed-off-by: Partha Pratim Mukherjee <<a href="mailto:ppm.floss@gmail.com">ppm.floss@gmail.com</a>><br>
---<br>
 src/bin/lttng/commands/set_session.c |   25 +++++++++++++++++++++++++<br>
 1 file changed, 25 insertions(+)<br>
<br>
diff --git a/src/bin/lttng/commands/set_session.c b/src/bin/lttng/commands/set_session.c<br>
index 3196f12..14fe9af 100644<br>
--- a/src/bin/lttng/commands/set_session.c<br>
+++ b/src/bin/lttng/commands/set_session.c<br>
@@ -106,11 +106,34 @@ end:<br>
 static int set_session(void)<br>
 {<br>
        int ret = CMD_SUCCESS;<br>
+       int count, i;<br>
+       unsigned int session_found = 0;<br>
+       struct lttng_session *sessions;<br>
<br>
        if (opt_session_name && strlen(opt_session_name) > NAME_MAX) {<br>
                ERR("Session name too long. Length must be lower or equal to %d",<br>
                        NAME_MAX);<br>
                ret = CMD_ERROR;<br>
+               goto end;<br>
+       }<br>
+<br>
+       count = lttng_list_sessions(&sessions);<br>
+       if (count < 0) {<br>
+               ret = CMD_ERROR;<br>
+               ERR("%s", lttng_strerror(count));<br>
+               goto end;<br>
+       }<br>
+<br>
+       for (i = 0; i < count; i++) {<br>
+               if (strncmp(sessions[i].name, opt_session_name, NAME_MAX) == 0) {<br>
+                       session_found = 1;<br>
+                       break;<br>
+               }<br>
+       }<br>
+<br>
+       if (!session_found) {<br>
+               ERR("Session '%s' not found", opt_session_name);<br>
+               ret = CMD_ERROR;<br>
                goto error;<br>
        }<br>
<br>
@@ -133,6 +156,8 @@ static int set_session(void)<br>
        ret = CMD_SUCCESS;<br>
<br>
 error:<br>
+       free(sessions);<br>
+end:<br>
        return ret;<br>
 }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.7.10.4<br>
<br>
_______________________________________________<br>
lttng-dev mailing list<br>
<a href="mailto:lttng-dev@lists.lttng.org">lttng-dev@lists.lttng.org</a><br>
<a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" rel="noreferrer" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div>