everywhere: use strlcpy and strlcat where appropriate

feature/tap-sh pkgconf-0.2
William Pitcock 2012-04-30 06:06:13 +00:00
parent 863498bfad
commit 3b154d8a5a
2 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* parse.c
* Parser for .pc file.
*
* Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org>.
* Copyright (c) 2011, 2012 William Pitcock <nenolod@dereferenced.org>.
*
* 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)

9
pkg.c
View File

@ -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;