Also on style: No function calls should be used to initialize
variables in definition statements. Use separate assignments in
this case.
copyname(char *dst, char *src)
{
size_t len;
- char *sep = strchr(src, ':');
+ char *cp, *sep;
- if (!sep) {
+ if (!(sep = strchr(src, ':'))) {
return 0;
}
+ /* whitespace is forbidden in name */
+ for (cp=src; cp<sep; cp++) {
+ if (isspace(*cp)) {
+ return 0;
+ }
+ }
len = sep - src;
if (len >= NAMESZ) {