Branch: Tag:

2016-06-17

2016-06-17 15:34:34 by Henrik Grubbström (Grubba) <grubba@grubba.org>

combine_path: Survive string_builder without NUL-terminations.

The string_builder API no longer maintains NUL-termination of the
buffer. This caused combine_path_nt() et al to fail intermittently
due to reading past the buffer end.

Also adds a corresponding test.

Fixes [bug 7723 (#7723)].

10714:   // - combine_path_unix   test_eq([[combine_path_unix("/","/fo\1111/bar/gazonk/../../")]],"/fo\1111/")    + // - append_path_nt + test_any([[ +  // Bug 7723. +  int i; +  for (i = 0; i < 1000; i++) { +  array(string) a = (array(string))(({""}) + allocate(5, random)(10000)); +  string ret = Stdio.append_path_nt("/", a*"/"); +  if (ret != (a*"/")) { +  return sprintf("%d: %O != %O\n", i, ret, a*"/"); +  } +  } +  return ""; + ]], "") +    // - compile   // - compile_file