diff --git a/parse.c b/parse.c index 6bf6e3d..b570399 100644 --- a/parse.c +++ b/parse.c @@ -2,7 +2,7 @@ * parse.c * Parser for .pc file. * - * Copyright (c) 2011 William Pitcock . + * Copyright (c) 2011, 2012 William Pitcock . * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -22,6 +22,7 @@ */ #include "pkg.h" +#include "bsdstubs.h" static pkg_tuple_t * tuple_add(pkg_tuple_t *parent, const char *key, const char *value) @@ -186,8 +187,8 @@ parse_deplist(pkg_t *pkg, const char *depends) char *vstart = NULL; char *package, *version; - strncpy(buf, kvdepends, BUFSIZ); - strncat(buf, " ", BUFSIZ); + strlcpy(buf, kvdepends, sizeof buf); + strlcat(buf, " ", sizeof buf); free(kvdepends); while (*ptr) diff --git a/pkg.c b/pkg.c index 2ce3605..5cf5e97 100644 --- a/pkg.c +++ b/pkg.c @@ -22,6 +22,7 @@ */ #include "pkg.h" +#include "bsdstubs.h" #define PKG_CONFIG_EXT ".pc" #define PKG_CONFIG_PATH_SZ (65535) @@ -32,19 +33,17 @@ pkg_get_pkgconfig_path(void) static bool computed = false; static char path[PKG_CONFIG_PATH_SZ]; char *env_path; - size_t len; if (computed) return path; - strncpy(path, PKG_DEFAULT_PATH, sizeof path); - len = strlen(PKG_DEFAULT_PATH); + strlcpy(path, PKG_DEFAULT_PATH, sizeof path); env_path = getenv("PKG_CONFIG_PATH"); if (env_path != NULL) { - strncat(path, ":", sizeof path - len - 1); - strncat(path, env_path, sizeof path - len - 2); + strlcat(path, ":", sizeof path); + strlcat(path, env_path, sizeof path); } return path;