pax: workaround for mkstemp() and long filenames
. symptom: mkstemp() looping forever trying to find a unique filename . reported by pikpik as "BSDTar Endless Extraction of NCurses' Distfiles"
This commit is contained in:
parent
e286ccc05b
commit
faa032f15c
1 changed files with 15 additions and 0 deletions
|
@ -160,8 +160,23 @@ file_creat(ARCHD *arcn, int write_to_hardlink)
|
||||||
* in the path until chk_path() finds that it cannot fix
|
* in the path until chk_path() finds that it cannot fix
|
||||||
* anything further. if that happens we just give up.
|
* anything further. if that happens we just give up.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __minix
|
||||||
|
{
|
||||||
|
/* For minix, generate the temporary filename
|
||||||
|
* conservatively - just write Xes into the last component.
|
||||||
|
* There is space because of the malloc().
|
||||||
|
*/
|
||||||
|
int cc;
|
||||||
|
char *last_slash;
|
||||||
|
strcpy(arcn->tmp_name, arcn->name);
|
||||||
|
if(!(last_slash = strrchr(arcn->tmp_name, '/')))
|
||||||
|
strcpy(arcn->tmp_name, "XXXXXX");
|
||||||
|
else strcpy(last_slash+1, "XXXXXX");
|
||||||
|
}
|
||||||
|
#else
|
||||||
(void)snprintf(arcn->tmp_name, arcn->nlen + 8, "%s.XXXXXX",
|
(void)snprintf(arcn->tmp_name, arcn->nlen + 8, "%s.XXXXXX",
|
||||||
arcn->name);
|
arcn->name);
|
||||||
|
#endif
|
||||||
fd = mkstemp(arcn->tmp_name);
|
fd = mkstemp(arcn->tmp_name);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue