s3:libsmb: fix NetServerEnum3 rap calls.
authorStefan Metzmacher <metze@samba.org>
Mon, 8 Feb 2010 17:38:03 +0000 (18:38 +0100)
committerKarolin Seeger <kseeger@samba.org>
Thu, 11 Feb 2010 10:28:53 +0000 (11:28 +0100)
metze
(cherry picked from commit 9b5198dd443a00fdad4faa1f9cdabedd81012d93)

source3/libsmb/clirap.c

index 9705cac7d758288f45720070734182cdef4d8aa6..36b137e45d780c7f075c129d9d442e06b1122bfd 100644 (file)
@@ -247,11 +247,9 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                p = param;
                SIVAL(p,0,func); /* api number */
                p += 2;
-               /* Next time through we need to use the continue api */
-               func = RAP_NetServerEnum3;
 
-               if (last_entry) {
-                       strlcpy(p,"WrLehDOz", sizeof(param)-PTR_DIFF(p,param));
+               if (func == RAP_NetServerEnum3) {
+                       strlcpy(p,"WrLehDzz", sizeof(param)-PTR_DIFF(p,param));
                } else {
                        strlcpy(p,"WrLehDz", sizeof(param)-PTR_DIFF(p,param));
                }
@@ -270,7 +268,7 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                 * to continue from.
                 */
                len = push_ascii(p,
-                               last_entry ? last_entry : workgroup,
+                               workgroup,
                                sizeof(param) - PTR_DIFF(p,param) - 1,
                                STR_TERMINATE|STR_UPPER);
 
@@ -280,6 +278,22 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                }
                p += len;
 
+               if (func == RAP_NetServerEnum3) {
+                       len = push_ascii(p,
+                                       last_entry ? last_entry : "",
+                                       sizeof(param) - PTR_DIFF(p,param) - 1,
+                                       STR_TERMINATE);
+
+                       if (len == (size_t)-1) {
+                               SAFE_FREE(last_entry);
+                               return false;
+                       }
+                       p += len;
+               }
+
+               /* Next time through we need to use the continue api */
+               func = RAP_NetServerEnum3;
+
                if (!cli_api(cli,
                        param, PTR_DIFF(p,param), 8, /* params, length, max */
                        NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */