if ((st.st_dev == netst.st_dev) &&
(st.st_ino == netst.st_ino)) {
- strncpy(name, entry->d_name, len - 1);
- name[len - 1] = '\0';
+ strlcpy(name, entry->d_name, len);
}
}
closedir(dir);
invarg("\"segs\" provided before \"mode\"\n",
*argv);
- strncpy(segbuf, *argv, 1024);
- segbuf[1023] = 0;
+ strlcpy(segbuf, *argv, 1024);
} else if (strcmp(*argv, "hmac") == 0) {
NEXT_ARG();
if (hmac_ok++)
if (vrf)
*vrf = '\0';
- strncpy(vpath, start, len - 1);
- vpath[len - 1] = '\0';
+ strlcpy(vpath, start, len);
/* if vrf path is just / then return nothing */
if (!strcmp(vpath, "/"))
ret = bpf_valid_mntpt(mntpt, magic);
if (!ret) {
- strncpy(mnt, mntpt, len - 1);
- mnt[len - 1] = 0;
+ strlcpy(mnt, mntpt, len);
return mnt;
}
if (nl)
*nl = '\0';
- strncpy(comm, name, len - 1);
- comm[len - 1] = '\0';
+ strlcpy(comm, name, len);
break;
}
free(ncache);
icache = proto;
ncache = strdup(pe->p_name);
- strncpy(buf, pe->p_name, len - 1);
- buf[len - 1] = '\0';
+ strlcpy(buf, pe->p_name, len);
return buf;
}
snprintf(buf, len, "ipproto-%d", proto);
user_ent_hash_build_init = 1;
- strncpy(name, root, sizeof(name)-1);
- name[sizeof(name)-1] = 0;
+ strlcpy(name, root, sizeof(name));
if (strlen(name) == 0 || name[strlen(name)-1] != '/')
strcat(name, "/");
int res;
req.op = IP_SET_OP_GET_BYNAME;
- strncpy(req.set.name, setname, IPSET_MAXNAMELEN);
- req.set.name[IPSET_MAXNAMELEN - 1] = '\0';
+ strlcpy(req.set.name, setname, IPSET_MAXNAMELEN);
res = do_getsockopt(&req);
if (res != 0)
return -1;