sockopt: Short circuit most of the code in soopt_from_kbuf(), if len == 0
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 5 Sep 2009 03:27:25 +0000 (11:27 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 5 Sep 2009 03:27:25 +0000 (11:27 +0800)
Current kva_p() does not work w/ zero sized kmalloced memory.

Dragonfly-bug: http://bugs.dragonflybsd.org/issue1481

sys/kern/uipc_socket.c

index e6f2ca2..5e724f2 100644 (file)
@@ -1460,6 +1460,11 @@ soopt_from_kbuf(struct sockopt *sopt, const void *buf, size_t len)
 {
        size_t  valsize;
 
+       if (len == 0) {
+               sopt->sopt_valsize = 0;
+               return;
+       }
+
        KKASSERT(!sopt->sopt_val || kva_p(sopt->sopt_val));
        KKASSERT(kva_p(buf));