Add ssizeof macro that returns ssize_t.
We can use this instead of casting the result of size_t to int. Also change checks for snprintf() returning <=0 to <0.
This commit is contained in:
@@ -142,7 +142,7 @@ find_path(const char *infile, char **outfile, struct stat *sbp,
|
||||
*/
|
||||
len = snprintf(command, sizeof(command), "%.*s/%s",
|
||||
(int)(ep - cp), cp, infile);
|
||||
if (len <= 0 || len >= (int)sizeof(command)) {
|
||||
if (len < 0 || len >= ssizeof(command)) {
|
||||
errno = ENAMETOOLONG;
|
||||
debug_return_int(NOT_FOUND_ERROR);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ find_path(const char *infile, char **outfile, struct stat *sbp,
|
||||
*/
|
||||
if (!found && checkdot) {
|
||||
len = snprintf(command, sizeof(command), "./%s", infile);
|
||||
if (len <= 0 || len >= (int)sizeof(command)) {
|
||||
if (len < 0 || len >= ssizeof(command)) {
|
||||
errno = ENAMETOOLONG;
|
||||
debug_return_int(NOT_FOUND_ERROR);
|
||||
}
|
||||
|
Reference in New Issue
Block a user