gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35700 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r35700 - gnunet/src/cadet
Date: Fri, 1 May 2015 10:25:08 +0200

Author: grothoff
Date: 2015-05-01 10:25:08 +0200 (Fri, 01 May 2015)
New Revision: 35700

Modified:
   gnunet/src/cadet/gnunet-service-cadet_tunnel.c
Log:
handle case where type is neither ENCRYPTED nor AX

Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2015-05-01 08:22:41 UTC 
(rev 35699)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2015-05-01 08:25:08 UTC 
(rev 35700)
@@ -3088,23 +3088,30 @@
   unsigned int off;
 
   type = ntohs (msg->type);
-  if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type)
+  switch (type)
   {
-    const struct GNUNET_CADET_Encrypted *emsg;
+  case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
+    {
+      const struct GNUNET_CADET_Encrypted *emsg;
 
-    emsg = (struct GNUNET_CADET_Encrypted *) msg;
-    payload_size = size - sizeof (struct GNUNET_CADET_Encrypted);
-    decrypted_size = t_decrypt_and_validate (t, cbuf, &emsg[1], payload_size,
-                                             emsg->iv, &emsg->hmac);
-  }
-  else if (GNUNET_MESSAGE_TYPE_CADET_AX == type)
-  {
-    const struct GNUNET_CADET_AX *emsg;
+      emsg = (struct GNUNET_CADET_Encrypted *) msg;
+      payload_size = size - sizeof (struct GNUNET_CADET_Encrypted);
+      decrypted_size = t_decrypt_and_validate (t, cbuf, &emsg[1], payload_size,
+                                               emsg->iv, &emsg->hmac);
+    }
+    break;
+  case GNUNET_MESSAGE_TYPE_CADET_AX:
+    {
+      const struct GNUNET_CADET_AX *emsg;
 
-    emsg = (struct GNUNET_CADET_AX *) msg;
-    decrypted_size = t_ax_decrypt_and_validate (t, cbuf, emsg, size);
+      emsg = (struct GNUNET_CADET_AX *) msg;
+      decrypted_size = t_ax_decrypt_and_validate (t, cbuf, emsg, size);
+    }
+    break;
+  default:
+    GNUNET_break_op (0);
+    return;
   }
-
   if (-1 == decrypted_size)
   {
     GNUNET_break_op (0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]