soopt_from_kbuf: Use szmin(), since both len and sopt_valsize is size_t
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 5 Sep 2009 03:52:32 +0000 (11:52 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 5 Sep 2009 03:52:32 +0000 (11:52 +0800)
Mainly to avoid integer truncation on 64bit platform.

Reminded-by: dillon@
sys/kern/uipc_socket.c

index 5e724f2..3f91b79 100644 (file)
@@ -1477,7 +1477,7 @@ soopt_from_kbuf(struct sockopt *sopt, const void *buf, size_t len)
         * Note that this interface is not idempotent; the entire answer must
         * generated ahead of time.
         */
-       valsize = min(len, sopt->sopt_valsize);
+       valsize = szmin(len, sopt->sopt_valsize);
        sopt->sopt_valsize = valsize;
        if (sopt->sopt_val != 0) {
                bcopy(buf, sopt->sopt_val, valsize);