Browse code

bb12220: Converting strnlen() calls to cli_strnlen() for systems such as Solaris 10 where strnlen() is not available. Adding #else clause to cli_get_filepath_from_filedesc() for platforms where we have not implemented a mechanism to determine the filename from the file descriptor.

Micah Snyder (micasnyd) authored on 2018/11/16 23:24:10
Showing 2 changed files
... ...
@@ -1023,7 +1023,7 @@ cl_error_t cli_get_filepath_from_filedesc(int desc, char** filepath)
1023 1023
 	/* Success. Add null terminator */
1024 1024
 	fname[linksz] = '\0';
1025 1025
 
1026
-    *filepath = cli_strndup(fname, strnlen(fname, PATH_MAX));
1026
+    *filepath = cli_strndup(fname, cli_strnlen(fname, PATH_MAX));
1027 1027
 	if (NULL == *filepath) {
1028 1028
 		cli_errmsg("cli_get_filepath_from_filedesc: Failed to allocate memory to store filename\n");
1029 1029
 		status = CL_EMEM;
... ...
@@ -1040,7 +1040,7 @@ cl_error_t cli_get_filepath_from_filedesc(int desc, char** filepath)
1040 1040
         goto done;
1041 1041
     }
1042 1042
 
1043
-    *filepath = cli_strndup(fname, strnlen(fname, PATH_MAX));
1043
+    *filepath = cli_strndup(fname, cli_strnlen(fname, PATH_MAX));
1044 1044
 	if (NULL == *filepath) {
1045 1045
 		cli_errmsg("cli_get_filepath_from_filedesc: Failed to allocate memory to store filename\n");
1046 1046
 		status = CL_EMEM;
... ...
@@ -1074,6 +1074,13 @@ cl_error_t cli_get_filepath_from_filedesc(int desc, char** filepath)
1074 1074
 		goto done;
1075 1075
 	}
1076 1076
 
1077
+#else
1078
+
1079
+	cli_dbgmsg("cli_get_filepath_from_filedesc: No mechanism implemented to determine filename from file descriptor.\n");
1080
+	*filename = NULL;
1081
+	status = CL_BREAK;
1082
+	goto done;
1083
+
1077 1084
 #endif
1078 1085
 
1079 1086
 	cli_errmsg("cli_get_filepath_from_filedesc: File path for fd [%d] is: %s\n", desc, *filepath);
... ...
@@ -1082,4 +1089,4 @@ cl_error_t cli_get_filepath_from_filedesc(int desc, char** filepath)
1082 1082
 done:
1083 1083
 
1084 1084
     return status;
1085
-}
1086 1085
\ No newline at end of file
1086
+}
... ...
@@ -1131,7 +1131,7 @@ cl_error_t cli_basename(const char *filepath, size_t filepath_len, char **fileba
1131 1131
     if ((index != filepath) || (index[0] == PATHSEP[0]))
1132 1132
         index++;
1133 1133
 
1134
-    if (0 == strnlen(index, filepath_len - (index - filepath))) {
1134
+    if (0 == cli_strnlen(index, filepath_len - (index - filepath))) {
1135 1135
         cli_dbgmsg("cli_basename: Provided path does not include a file name.\n");
1136 1136
         status = CL_EFORMAT;
1137 1137
         goto done;