X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fiwinfo.git;a=blobdiff_plain;f=iwinfo_utils.c;h=3090c4cde4a3711fb45b7af22d0d9a52adf5371d;hp=96542072f53cbb916d22f44b399f8931569259ef;hb=HEAD;hpb=d5dc3d0605f76fbbbad005d998497e53a236aeda diff --git a/iwinfo_utils.c b/iwinfo_utils.c index 9654207..3090c4c 100644 --- a/iwinfo_utils.c +++ b/iwinfo_utils.c @@ -81,7 +81,7 @@ int iwinfo_ifup(const char *ifname) { struct ifreq ifr; - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr)) return 0; @@ -95,7 +95,7 @@ int iwinfo_ifdown(const char *ifname) { struct ifreq ifr; - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr)) return 0; @@ -109,7 +109,7 @@ int iwinfo_ifmac(const char *ifname) { struct ifreq ifr; - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); if (iwinfo_ioctl(SIOCGIFHWADDR, &ifr)) return 0; @@ -177,13 +177,14 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id) FILE *mtd; uint16_t *bc; - int fd, len, off; + int fd, off; + unsigned int len; char buf[128]; if (!(mtd = fopen("/proc/mtd", "r"))) return -1; - while (fgets(buf, sizeof(buf), mtd) > 0) + while (fgets(buf, sizeof(buf), mtd) != NULL) { if (fscanf(mtd, "mtd%d: %x %*x %127s", &off, &len, buf) < 3 || (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") && @@ -246,7 +247,7 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id) id->subsystem_vendor_id = 0x1814; /* device */ - if (bc[off] & 0xf0 == 0x30) + if ((bc[off] & 0xf0) == 0x30) id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8; else id->device_id = bc[off];