s4:wb_cmd_list_groups.c - don't crash when we don't get any group at all
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sun, 4 Jul 2010 19:22:28 +0000 (21:22 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sun, 4 Jul 2010 20:05:17 +0000 (22:05 +0200)
source4/winbind/wb_cmd_list_groups.c

index 37fe94a5de3baca67db76dd73e433d6f0ecdb55a..16059ea4cc069d1557f41b450e95f5602c2c5e9f 100644 (file)
@@ -154,9 +154,11 @@ static void cmd_list_groups_recv_group_list(struct composite_context *ctx)
        /* If the status is OK, we're finished, there's no more groups.
         * So we'll trim off the trailing ',' and are done.*/
        if (NT_STATUS_IS_OK(status)) {
-               int str_len = strlen(state->result);
+               size_t str_len = strlen(state->result);
                DEBUG(5, ("list_GroupList_recv returned NT_STATUS_OK\n"));
-               state->result[str_len - 1] = '\0';
+               if (str_len > 0) {
+                       state->result[str_len - 1] = '\0';
+               }
                composite_done(state->ctx);
                return;
        }