summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Kos <okos@redhat.com>2013-04-03 12:33:30 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-04-04 23:57:36 +0200
commit3d3056b38061386a49ca793e08ce52e8c5562f46 (patch)
treee8d0996dc13f303e367ae050b1029ec1dbca4043
parent736ccbe7930f443d7d381d93d8cf89665345f36a (diff)
downloadding-libs-3d3056b38061386a49ca793e08ce52e8c5562f46.tar.gz
ding-libs-3d3056b38061386a49ca793e08ce52e8c5562f46.tar.xz
ding-libs-3d3056b38061386a49ca793e08ce52e8c5562f46.zip
PATH_UTILS: check against character representation of NULL
https://fedorahosted.org/sssd/ticket/1859
-rw-r--r--path_utils/path_utils.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/path_utils/path_utils.c b/path_utils/path_utils.c
index a9ae7b3..61605ab 100644
--- a/path_utils/path_utils.c
+++ b/path_utils/path_utils.c
@@ -102,7 +102,7 @@ static int dot_to_absolute(char *rel_path, int rel_path_size)
return errno;
}
strncpy(rel_path, dirname(tmp_path), rel_path_size);
- if (rel_path[rel_path_size-1] != 0) return ENOBUFS;
+ if (rel_path[rel_path_size-1] != '\0') return ENOBUFS;
}
return SUCCESS;
@@ -117,9 +117,9 @@ int get_basename(char *base_name, size_t base_name_size, const char *path)
if (!base_name || base_name_size < 1) return ENOBUFS;
strncpy(tmp_path, path, sizeof(tmp_path));
- if (tmp_path[sizeof(tmp_path)-1] != 0) return ENOBUFS;
+ if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
strncpy(base_name, basename(tmp_path), base_name_size);
- if (base_name[base_name_size-1] != 0) return ENOBUFS;
+ if (base_name[base_name_size-1] != '\0') return ENOBUFS;
ret = dot_to_absolute(base_name, base_name_size);
if (ret != SUCCESS) {
@@ -138,9 +138,9 @@ int get_dirname(char *dir_path, size_t dir_path_size, const char *path)
if (!dir_path || dir_path_size < 1) return ENOBUFS;
strncpy(tmp_path, path, sizeof(tmp_path));
- if (tmp_path[sizeof(tmp_path)-1] != 0) return ENOBUFS;
+ if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
strncpy(dir_path, dirname(tmp_path), dir_path_size);
- if (dir_path[dir_path_size-1] != 0) return ENOBUFS;
+ if (dir_path[dir_path_size-1] != '\0') return ENOBUFS;
ret = dot_to_absolute(dir_path, dir_path_size);
if (ret != SUCCESS) {
@@ -162,14 +162,14 @@ int get_directory_and_base_name(char *dir_path, size_t dir_path_size,
if (!base_name || base_name_size < 1) return ENOBUFS;
strncpy(tmp_path, path, sizeof(tmp_path));
- if (tmp_path[sizeof(tmp_path)-1] != 0) return ENOBUFS;
+ if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
strncpy(base_name, basename(tmp_path), base_name_size);
- if (base_name[base_name_size-1] != 0) return ENOBUFS;
+ if (base_name[base_name_size-1] != '\0') return ENOBUFS;
strncpy(tmp_path, path, sizeof(tmp_path));
- if (tmp_path[sizeof(tmp_path)-1] != 0) return ENOBUFS;
+ if (tmp_path[sizeof(tmp_path)-1] != '\0') return ENOBUFS;
strncpy(dir_path, dirname(tmp_path), dir_path_size);
- if (dir_path[dir_path_size-1] != 0) return ENOBUFS;
+ if (dir_path[dir_path_size-1] != '\0') return ENOBUFS;
ret = dot_to_absolute(dir_path, dir_path_size);
if (ret != SUCCESS) {
@@ -178,7 +178,7 @@ int get_directory_and_base_name(char *dir_path, size_t dir_path_size,
if (strcmp(base_name, ".") == 0) {
strncpy(base_name, "", base_name_size);
- if (base_name[base_name_size-1] != 0) return ENOBUFS;
+ if (base_name[base_name_size-1] != '\0') return ENOBUFS;
}
return SUCCESS;
@@ -529,7 +529,7 @@ int find_existing_directory_ancestor(char *ancestor, size_t ancestor_size, const
if (!ancestor || ancestor_size < 1) return ENOBUFS;
*ancestor = 0;
strncpy(dir_path, path, sizeof(dir_path));
- if (dir_path[sizeof(dir_path)-1] != 0) return ENOBUFS;
+ if (dir_path[sizeof(dir_path)-1] != '\0') return ENOBUFS;
while (strcmp(dir_path, "/") != 0) {
if (lstat(dir_path, &info) < 0) {
@@ -545,7 +545,7 @@ int find_existing_directory_ancestor(char *ancestor, size_t ancestor_size, const
}
strncpy(ancestor, dir_path, ancestor_size);
- if (ancestor[ancestor_size-1] != 0) return ENOBUFS;
+ if (ancestor[ancestor_size-1] != '\0') return ENOBUFS;
return SUCCESS;
}