]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
profile: set proper level in REQ_PROFILELEVEL
authorShachar Sharon <ssharon@redhat.com>
Mon, 13 Apr 2026 08:22:01 +0000 (11:22 +0300)
committerAnoop C S <anoopcs@samba.org>
Thu, 21 May 2026 05:38:37 +0000 (05:38 +0000)
Set proper level value, within valid range [0,2], for MSG_PROFILELEVEL.
Fixes a bug in existing code where return 'level' my be in non-valid
values 3 or 7.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source3/profile/profile.c

index b4820f3747743d5844804fdb95a43c4297d3e20f..0465f0f5cd59928a08dabe63f75842c480f1f417 100644 (file)
@@ -84,7 +84,7 @@ static void profile_message(struct messaging_context *msg_ctx,
                            struct server_id src,
                            DATA_BLOB *data)
 {
-        int level;
+       int level;
 
        if (data->length != sizeof(level)) {
                DEBUG(0, ("got invalid profile message\n"));
@@ -104,14 +104,14 @@ static void reqprofile_message(struct messaging_context *msg_ctx,
                               struct server_id src,
                               DATA_BLOB *data)
 {
-        int level;
-
-       level = 1;
-       if (smbprofile_state.config.do_count) {
-               level += 2;
-       }
-       if (smbprofile_state.config.do_times) {
-               level += 4;
+       int level;
+
+       if (!smbprofile_state.config.do_count) {
+               level = 0;
+       } else if (!smbprofile_state.config.do_times) {
+               level = 1;
+       } else {
+               level = 2;
        }
 
        DEBUG(1,("INFO: Received REQ_PROFILELEVEL message from PID %u\n",