]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 23 Jan 2013 18:32:26 +0000 (18:32 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 23 Jan 2013 18:32:26 +0000 (18:32 +0000)
MagickCore/distribute-cache.c

index 491a62319d27b4c406a0e1e5084f939496d9dd2c..1aceee3ff3bda5be91c2e5faac2374a148b7bc5a 100644 (file)
@@ -190,13 +190,16 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
   MagickOffsetType
     count;
 
+  register unsigned char
+    *p;
+
   struct addrinfo
     hint,
     *result;
 
   unsigned char
     secret[MaxTextExtent],
-    session[MaxTextExtent];
+    session[2*MaxTextExtent];
 
   /*
     Connect to distributed pixel cache and get session key.
@@ -209,8 +212,9 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
         "DistributedPixelCache","'%s'","shared secret expected");
       return(-1);
     }
-  (void) CopyMagickString((char *) session,shared_secret,MaxTextExtent-
-    DPCSessionKeyLength);
+  p=session;
+  (void) CopyMagickString((char *) p,shared_secret,MaxTextExtent);
+  p+=strlen(shared_secret);
   (void) ResetMagickMemory(&hint,0,sizeof(hint));
   hint.ai_family=AF_INET;
   hint.ai_socktype=SOCK_STREAM;
@@ -241,8 +245,19 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
   count=dpc_read(client_socket,MaxTextExtent,secret);
   if (count != -1)
     {
-      (void) memcpy(session+strlen(shared_secret),secret,(size_t) count);
-      *session_key=CRC64(session,(MagickSizeType) strlen(shared_secret)+count);
+      MagickSizeType
+        hdri,
+        quantum_depth;
+
+      (void) memcpy(p,secret,(size_t) count);
+      p+=count;
+      quantum_depth=MAGICKCORE_QUANTUM_DEPTH;
+      (void) memcpy(p,&quantum_depth,sizeof(quantum_depth));
+      p+=sizeof(quantum_depth);
+      hdri=MAGICKCORE_HDRI_ENABLE;
+      (void) memcpy(p,&hdri,sizeof(hdri));
+      p+=sizeof(hdri);
+      *session_key=CRC64(session,p-session);
     }
   if (*session_key == 0)
     {
@@ -641,7 +656,6 @@ static MagickBooleanType WriteDistributeCacheMetacontent(
     Write distributed pixel cache metacontent.
   */
   image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);
-  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);
   if (image == (Image *) NULL)
     return(MagickFalse);
   length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+
@@ -750,9 +764,14 @@ static void *DistributePixelCacheClient(void *socket)
     count;
 
   MagickSizeType
+    hdri,
+    quantum_depth,
     key,
     session_key;
 
+  register unsigned char
+    *p;
+
   RandomInfo
     *random_info;
 
@@ -764,7 +783,7 @@ static void *DistributePixelCacheClient(void *socket)
 
   unsigned char
     command,
-    session[MaxTextExtent];
+    session[2*MaxTextExtent];
 
   /*
     Distributed pixel cache client.
@@ -772,13 +791,20 @@ static void *DistributePixelCacheClient(void *socket)
   shared_secret=GetPolicyValue("shared-secret");
   if (shared_secret == (const char *) NULL)
     ThrowFatalException(CacheFatalError,"shared secret expected");
-  (void) CopyMagickString((char *) session,shared_secret,MaxTextExtent-
-    DPCSessionKeyLength);
+  p=session;
+  (void) CopyMagickString((char *) p,shared_secret,MaxTextExtent);
+  p+=strlen(shared_secret);
   random_info=AcquireRandomInfo();
   secret=GetRandomKey(random_info,DPCSessionKeyLength);
-  (void) memcpy(session+strlen(shared_secret),GetStringInfoDatum(secret),
-    DPCSessionKeyLength);
-  session_key=CRC64(session,strlen(shared_secret)+DPCSessionKeyLength);
+  (void) memcpy(p,GetStringInfoDatum(secret),DPCSessionKeyLength);
+  p+=DPCSessionKeyLength;
+  quantum_depth=MAGICKCORE_QUANTUM_DEPTH;
+  (void) memcpy(p,&quantum_depth,sizeof(quantum_depth));
+  p+=sizeof(quantum_depth);
+  hdri=MAGICKCORE_HDRI_ENABLE;
+  (void) memcpy(p,&hdri,sizeof(hdri));
+  p+=sizeof(hdri);
+  session_key=CRC64(session,p-session);
   random_info=DestroyRandomInfo(random_info);
   exception=AcquireExceptionInfo();
   registry=NewSplayTree((int (*)(const void *,const void *)) NULL,
@@ -792,7 +818,7 @@ static void *DistributePixelCacheClient(void *socket)
     if (count <= 0)
       break;
     count=dpc_read(client_socket,sizeof(key),(unsigned char *) &key);
-    if ((count != (MagickOffsetType) sizeof(key)) && (key != session_key))
+    if ((count != (MagickOffsetType) sizeof(key)) || (key != session_key))
       break;
     status=MagickFalse;
     switch (command)