diff -urNP netkit-bootparamd-0.17-pre20000412/rpc.bootparamd/bootparam_get_router.c netkit-bootparamd-0.17-pre20000412.new/rpc.bootparamd/bootparam_get_router.c --- netkit-bootparamd-0.17-pre20000412/rpc.bootparamd/bootparam_get_router.c 2010-11-04 16:44:37.000000000 -0400 +++ netkit-bootparamd-0.17-pre20000412.new/rpc.bootparamd/bootparam_get_router.c 2010-11-04 15:30:11.000000000 -0400 @@ -116,7 +116,7 @@ { struct sockaddr_in from; - int fromlen = sizeof(from); + u_int fromlen = sizeof(from); char buf[MAXPACKETLEN]; int nbytes, buflen = sizeof(buf); u_long routers[MAXNUMROUTERS]; @@ -166,8 +166,12 @@ msgout("Read %d bytes (%d)", nbytes, cnt); if ((router = (u_long)parse_pack((char *)buf, nbytes, &from)) != 0) { - routers[cnt] = router; - cnt++; + if (cnt < MAXNUMROUTERS) { + /* convert to host byte order for sorting */ + routers[cnt] = ntohl(router); + cnt++; + } else + break; } else { bpcnt++; @@ -188,11 +192,11 @@ for (i = 0; i < cnt; i++) { if (debug) - msgout("Routers %x (%d)", ntohl(routers[i]), i); + msgout("Routers %x (%d)", routers[i], i); } - /* return the one with lowest IP */ - return ((u_long)routers[0]); + /* return the one with lowest IP in network byte order */ + return ((u_long)htonl(routers[0])); } }