Don't use msg on error.
authorJan Hykel <jan.hykel@acision.com>
Sun, 16 Nov 2014 16:51:17 +0000 (16:51 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 17 Nov 2014 12:41:47 +0000 (12:41 +0000)
Don't attempt to access msg structure if recvmsg returns an error.

PR#3483
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 012aa9ec76b158179b4de44bb5de8b8472045eac)

crypto/bio/bss_dgram.c

index 9c0950191b9e049f42b63645c237368b814db195..db87f34175ce6950e0e53f7ff6115ea7f6e629d6 100644 (file)
@@ -1082,6 +1082,13 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
                        msg.msg_flags = 0;
                        n = recvmsg(b->num, &msg, 0);
 
+                       if (n <= 0)
+                               {
+                               if (n < 0)
+                                       ret = n;
+                               break;
+                               }
+
                        if (msg.msg_controllen > 0)
                                {
                                for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg))
@@ -1121,13 +1128,6 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
                                        }
                                }
 
-                       if (n <= 0)
-                               {
-                               if (n < 0)
-                                       ret = n;
-                               break;
-                               }
-
                        if (msg.msg_flags & MSG_NOTIFICATION)
                                {
                                snp = (union sctp_notification*) out;