s3-svcctl: fix memcpy in _svcctl_EnumServicesStatusW().
authorGünther Deschner <gd@samba.org>
Tue, 14 Apr 2009 10:08:55 +0000 (12:08 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 14 Apr 2009 10:13:24 +0000 (12:13 +0200)
Make sure we are not copying more than what we have as valid data.

Fix from Jeremy. Thanks a lot for watching this so closely!

Guenther

source3/rpc_server/srv_svcctl_nt.c

index 0b0ef83bee97c73613477149a0d15a02c3a164ac..d73f73f9eccfaad16075f80f144077f544f42e17 100644 (file)
@@ -464,9 +464,8 @@ WERROR _svcctl_EnumServicesStatusW(pipes_struct *p,
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        return ntstatus_to_werror(ndr_map_error2ntstatus(ndr_err));
                }
-
                blob = ndr_push_blob(ndr);
-               memcpy(r->out.service, blob.data, r->in.offered);
+               memcpy(r->out.service, blob.data, MIN(blob.length, r->in.offered));
        }
 
        *r->out.needed                  = (buffer_size > r->in.offered) ? buffer_size : r->in.offered;