r3867: Fix from david.hu@hp.com - make a copy of an incoming message
authorJeremy Allison <jra@samba.org>
Thu, 18 Nov 2004 22:46:04 +0000 (22:46 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:53:22 +0000 (10:53 -0500)
rather than indirecting into it as a struct (may not be on an
even byte boundary). Bug #2052.
Jeremy.
(This used to be commit 8a91a69961622a31851f2394c591ddaa61a36000)

source3/printing/printing.c

index 1e897c962a61ac7ab10334ebff999d77c0fecb8b..ca8394506588bc6baf9d1c74bee80c343a7dbba6 100644 (file)
@@ -1201,17 +1201,17 @@ this is the receive function of the background lpq updater
 ****************************************************************************/
 static void print_queue_receive(int msg_type, pid_t src, void *buf, size_t len)
 {
-       struct print_queue_update_context *ctx;
+       struct print_queue_update_context ctx;
 
        if (len != sizeof(struct print_queue_update_context)) {
                DEBUG(1, ("Got invalid print queue update message\n"));
                return;
        }
 
-       ctx = (struct print_queue_update_context*)buf;
-       print_queue_update_internal(ctx->sharename, 
-               get_printer_fns_from_type(ctx->printing_type),
-               ctx->lpqcommand );
+       memcpy(&ctx, buf, sizeof(struct print_queue_update_context));
+       print_queue_update_internal(ctx.sharename, 
+               get_printer_fns_from_type(ctx.printing_type),
+               ctx.lpqcommand );
 }
 
 static pid_t background_lpq_updater_pid = -1;