summaryrefslogtreecommitdiffstats
path: root/usr.bin/rpcgen
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2011-07-11 05:31:52 +0000
committerdelphij <delphij@FreeBSD.org>2011-07-11 05:31:52 +0000
commitd352e8628e0818b72aff4c4d5ee62bdedd753de7 (patch)
treea96add5cbcb886b8ff9edff4a599dc0cfce73a46 /usr.bin/rpcgen
parent972deb0b1f84a778df634f7aa995aca2b570beff (diff)
downloadFreeBSD-src-d352e8628e0818b72aff4c4d5ee62bdedd753de7.zip
FreeBSD-src-d352e8628e0818b72aff4c4d5ee62bdedd753de7.tar.gz
Use strlcpy().
MFC after: 1 month
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r--usr.bin/rpcgen/rpc_scan.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c
index 421b055..bdbeec0 100644
--- a/usr.bin/rpcgen/rpc_scan.c
+++ b/usr.bin/rpcgen/rpc_scan.c
@@ -329,10 +329,9 @@ findstrconst(char **str, const char **val)
error("unterminated string constant");
}
p++;
- size = p - *str;
- tmp = xmalloc(size + 1);
- (void) strncpy(tmp, *str, size);
- tmp[size] = 0;
+ size = p - *str + 1;
+ tmp = xmalloc(size);
+ (void) strlcpy(tmp, *str, size);
*val = tmp;
*str = p;
}
@@ -352,13 +351,12 @@ findchrconst(char **str, const char **val)
error("unterminated string constant");
}
p++;
- size = p - *str;
- if (size != 3) {
+ size = p - *str + 1;
+ if (size != 4) {
error("empty char string");
}
- tmp = xmalloc(size + 1);
- (void) strncpy(tmp, *str, size);
- tmp[size] = 0;
+ tmp = xmalloc(size);
+ (void) strlcpy(tmp, *str, size);
*val = tmp;
*str = p;
}
@@ -381,10 +379,9 @@ findconst(char **str, const char **val)
p++;
} while (isdigit(*p));
}
- size = p - *str;
- tmp = xmalloc(size + 1);
- (void) strncpy(tmp, *str, size);
- tmp[size] = 0;
+ size = p - *str + 1;
+ tmp = xmalloc(size);
+ (void) strlcpy(tmp, *str, size);
*val = tmp;
*str = p;
}
@@ -438,8 +435,7 @@ findkind(char **mark, token *tokp)
tokp->kind = TOK_IDENT;
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
tmp = xmalloc(len + 1);
- (void) strncpy(tmp, str, len);
- tmp[len] = 0;
+ (void) strlcpy(tmp, str, len + 1);
tokp->str = tmp;
*mark = str + len;
}
OpenPOWER on IntegriCloud