libsmb: Protect cli_RNetShareEnum() against rprcnt<6
authorVolker Lendecke <vl@samba.org>
Sat, 2 May 2020 12:59:07 +0000 (14:59 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 14 May 2020 07:18:23 +0000 (07:18 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 4a9fe4efefa67d6f24efcbe29722a43fc4859fdc)

source3/libsmb/clirap.c

index a703f4535568e255813d5127803a3dfd6644ab96..9b7f54c503b1edb2a0bb968a6382c963a9ecd0c7 100644 (file)
@@ -204,6 +204,11 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32_t,
                goto done;
        }
 
+       if (rprcnt < 6) {
+               DBG_ERR("Got invalid result: rprcnt=%u\n", rprcnt);
+               goto done;
+       }
+
        res = rparam? SVAL(rparam,0) : -1;
 
        if (res == 0 || res == ERRmoredata) {