Browse Source

Fixing bug 804.

Using function get_windows_canonical_path() may neglect the
ngspice file search sequence, as an absolute path is returned also
for relative input paths. ngspice however searches a file not only
relative to the current directory, as inforced by this
function, but for example also in the directory of the previous
input file.

So restrict this function to paths longer than MAX_PATH, which would fail
otherwise.
pre-master-46
Holger Vogt 7 months ago
parent
commit
aa3ab5bc25
  1. 8
      src/frontend/inpcom.c

8
src/frontend/inpcom.c

@ -9844,6 +9844,10 @@ static void inp_meas_control(struct card* card)
* might need to add the prefix separately if using the result in APIs * might need to add the prefix separately if using the result in APIs
* that require it for long path support. * that require it for long path support.
* *
* Using this function however may neglect the ngspice file search sequence,
* as an absolute path is returned also for relative paths.
* So restrict this function to paths longer than MAX_PATH.
*
* @param input_path The input path string (UTF-8 encoded). Can be relative or * @param input_path The input path string (UTF-8 encoded). Can be relative or
* absolute, may contain '.' or '..'. * absolute, may contain '.' or '..'.
* @return char* A newly allocated UTF-8 string containing the canonical absolute * @return char* A newly allocated UTF-8 string containing the canonical absolute
@ -9869,6 +9873,10 @@ char* get_windows_canonical_path(const char* input_path) {
inputLenMB = (int)strlen(input_path); inputLenMB = (int)strlen(input_path);
/* If path length is less than MAX_PATH, just copy and return path. */
if (inputLenMB < MAX_PATH)
return copy(input_path);
if (inputLenMB == 0) { if (inputLenMB == 0) {
inputLenW = 1; inputLenW = 1;
} }

Loading…
Cancel
Save