*
* x3 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
snprintf(mask, HOSTLEN, "%x.%x.%s.%s.%s",
hash[0], hash[1], parv2[parc2 - 3], parv2[parc2 - 2],
parv2[parc2 - 1]);
- } else {
+ } else if (parc2 >= 3) {
snprintf(mask, HOSTLEN, "%x.%x.%s.%s",
hash[0], hash[1], parv2[parc2 - 2],
parv2[parc2 - 1]);
+ } else if (parc2 >= 2) {
+ snprintf(mask, HOSTLEN, "%x.%x.%s",
+ hash[0], hash[1], parv2[parc2 - 1]);
+ } else {
+ snprintf(mask, HOSTLEN, "%x.%x",
+ hash[0], hash[1]);
}
}
safestrncpy (virt, mask, HOSTLEN);