|
Lines 1311-1316
UUDecode (uulist *data)
|
Link Here
|
|---|
|
char *mode, *ntmp; | char *mode, *ntmp; |
uufile *iter; | uufile *iter; |
size_t bytes; | size_t bytes; |
|
#ifdef HAVE_MKSTEMP |
|
int tmpfd; |
|
const char *tmpprefix = "uuXXXXXX"; |
|
char *tmpdir = NULL; |
|
#endif /* HAVE_MKSTEMP */ |
| |
if (data == NULL || data->thisfile == NULL) | if (data == NULL || data->thisfile == NULL) |
return UURET_ILLVAL; | return UURET_ILLVAL; |
|
Lines 1329-1341
UUDecode (uulist *data)
|
Link Here
|
|---|
|
else | else |
mode = "wb"; /* otherwise in binary */ | mode = "wb"; /* otherwise in binary */ |
| |
|
#ifdef HAVE_MKSTEMP |
|
if ((getuid()==geteuid()) && (getgid()==getegid())) { |
|
tmpdir=getenv("TMPDIR"); |
|
} |
|
|
|
if (!tmpdir) { |
|
tmpdir = "/tmp"; |
|
} |
|
data->binfile = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
|
|
|
if (!data->binfile) { |
|
#else |
if ((data->binfile = tempnam (NULL, "uu")) == NULL) { | if ((data->binfile = tempnam (NULL, "uu")) == NULL) { |
|
#endif /* HAVE_MKSTEMP */ |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
uustring (S_NO_TEMP_NAME)); | uustring (S_NO_TEMP_NAME)); |
return UURET_NOMEM; | return UURET_NOMEM; |
} | } |
| |
|
#ifdef HAVE_MKSTEMP |
|
strcpy(data->binfile, tmpdir); |
|
strcat(data->binfile, "/"); |
|
strcat(data->binfile, tmpprefix); |
|
|
|
if ((tmpfd = mkstemp(data->binfile)) == -1 || |
|
(dataout = fdopen(tmpfd, mode)) == NULL) { |
|
#else |
if ((dataout = fopen (data->binfile, mode)) == NULL) { | if ((dataout = fopen (data->binfile, mode)) == NULL) { |
|
#endif /* HAVE_MKSTEMP */ |
/* | /* |
* we couldn't create a temporary file. Usually this means that TMP | * we couldn't create a temporary file. Usually this means that TMP |
* and TEMP aren't set | * and TEMP aren't set |
|
Lines 1343-1353
UUDecode (uulist *data)
|
Link Here
|
|---|
|
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
uustring (S_WR_ERR_TARGET), | uustring (S_WR_ERR_TARGET), |
data->binfile, strerror (uu_errno = errno)); | data->binfile, strerror (uu_errno = errno)); |
|
#ifdef HAVE_MKSTEMP |
|
if (tmpfd != -1) { |
|
unlink(data->binfile); |
|
close(tmpfd); |
|
} |
|
#endif /* HAVE_MKSTEMP */ |
_FP_free (data->binfile); | _FP_free (data->binfile); |
data->binfile = NULL; | data->binfile = NULL; |
uu_errno = errno; | uu_errno = errno; |
return UURET_IOERR; | return UURET_IOERR; |
} | } |
|
|
/* | /* |
* we don't have begin lines in Base64 or plain text files. | * we don't have begin lines in Base64 or plain text files. |
*/ | */ |
|
Lines 1496-1502
UUDecode (uulist *data)
|
Link Here
|
|---|
|
*/ | */ |
| |
if (data->uudet == BH_ENCODED && data->binfile) { | if (data->uudet == BH_ENCODED && data->binfile) { |
|
#ifdef HAVE_MKSTEMP |
|
ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
|
|
|
if (ntmp == NULL) { |
|
#else |
if ((ntmp = tempnam (NULL, "uu")) == NULL) { | if ((ntmp = tempnam (NULL, "uu")) == NULL) { |
|
#endif /* HAVE_MKSTEMP */ |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
uustring (S_NO_TEMP_NAME)); | uustring (S_NO_TEMP_NAME)); |
progress.action = 0; | progress.action = 0; |
|
Lines 1510-1524
UUDecode (uulist *data)
|
Link Here
|
|---|
|
free (ntmp); | free (ntmp); |
return UURET_IOERR; | return UURET_IOERR; |
} | } |
|
|
|
#ifdef HAVE_MKSTEMP |
|
strcpy(ntmp, tmpdir); |
|
strcat(ntmp, "/"); |
|
strcat(ntmp, tmpprefix); |
|
if ((tmpfd = mkstemp(ntmp)) == -1 || |
|
(dataout = fdopen(tmpfd, "wb")) == NULL) { |
|
#else |
if ((dataout = fopen (ntmp, "wb")) == NULL) { | if ((dataout = fopen (ntmp, "wb")) == NULL) { |
|
#endif /* HAVE_MKSTEMP */ |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
uustring (S_NOT_OPEN_TARGET), | uustring (S_NOT_OPEN_TARGET), |
ntmp, strerror (uu_errno = errno)); | ntmp, strerror (uu_errno = errno)); |
progress.action = 0; | progress.action = 0; |
fclose (datain); | fclose (datain); |
|
#ifdef HAVE_MKSTEMP |
|
if (tmpfd != -1) { |
|
unlink(ntmp); |
|
close(tmpfd); |
|
} |
|
#endif /* HAVE_MKSTEMP */ |
free (ntmp); | free (ntmp); |
return UURET_IOERR; | return UURET_IOERR; |
} | } |
|
|
/* | /* |
* read fork lengths. remember they're in Motorola format | * read fork lengths. remember they're in Motorola format |
*/ | */ |