Lines 1311-1316
UUDecode (uulist *data)
Link Here
|
1311 |
char *mode, *ntmp; |
1311 |
char *mode, *ntmp; |
1312 |
uufile *iter; |
1312 |
uufile *iter; |
1313 |
size_t bytes; |
1313 |
size_t bytes; |
|
|
1314 |
#ifdef HAVE_MKSTEMP |
1315 |
int tmpfd; |
1316 |
const char *tmpprefix = "uuXXXXXX"; |
1317 |
char *tmpdir = NULL; |
1318 |
#endif /* HAVE_MKSTEMP */ |
1314 |
|
1319 |
|
1315 |
if (data == NULL || data->thisfile == NULL) |
1320 |
if (data == NULL || data->thisfile == NULL) |
1316 |
return UURET_ILLVAL; |
1321 |
return UURET_ILLVAL; |
Lines 1329-1341
UUDecode (uulist *data)
Link Here
|
1329 |
else |
1334 |
else |
1330 |
mode = "wb"; /* otherwise in binary */ |
1335 |
mode = "wb"; /* otherwise in binary */ |
1331 |
|
1336 |
|
|
|
1337 |
#ifdef HAVE_MKSTEMP |
1338 |
if ((getuid()==geteuid()) && (getgid()==getegid())) { |
1339 |
tmpdir=getenv("TMPDIR"); |
1340 |
} |
1341 |
|
1342 |
if (!tmpdir) { |
1343 |
tmpdir = "/tmp"; |
1344 |
} |
1345 |
data->binfile = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
1346 |
|
1347 |
if (!data->binfile) { |
1348 |
#else |
1332 |
if ((data->binfile = tempnam (NULL, "uu")) == NULL) { |
1349 |
if ((data->binfile = tempnam (NULL, "uu")) == NULL) { |
|
|
1350 |
#endif /* HAVE_MKSTEMP */ |
1333 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1351 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1334 |
uustring (S_NO_TEMP_NAME)); |
1352 |
uustring (S_NO_TEMP_NAME)); |
1335 |
return UURET_NOMEM; |
1353 |
return UURET_NOMEM; |
1336 |
} |
1354 |
} |
1337 |
|
1355 |
|
|
|
1356 |
#ifdef HAVE_MKSTEMP |
1357 |
strcpy(data->binfile, tmpdir); |
1358 |
strcat(data->binfile, "/"); |
1359 |
strcat(data->binfile, tmpprefix); |
1360 |
|
1361 |
if ((tmpfd = mkstemp(data->binfile)) == -1 || |
1362 |
(dataout = fdopen(tmpfd, mode)) == NULL) { |
1363 |
#else |
1338 |
if ((dataout = fopen (data->binfile, mode)) == NULL) { |
1364 |
if ((dataout = fopen (data->binfile, mode)) == NULL) { |
|
|
1365 |
#endif /* HAVE_MKSTEMP */ |
1339 |
/* |
1366 |
/* |
1340 |
* we couldn't create a temporary file. Usually this means that TMP |
1367 |
* we couldn't create a temporary file. Usually this means that TMP |
1341 |
* and TEMP aren't set |
1368 |
* and TEMP aren't set |
Lines 1343-1353
UUDecode (uulist *data)
Link Here
|
1343 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1370 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1344 |
uustring (S_WR_ERR_TARGET), |
1371 |
uustring (S_WR_ERR_TARGET), |
1345 |
data->binfile, strerror (uu_errno = errno)); |
1372 |
data->binfile, strerror (uu_errno = errno)); |
|
|
1373 |
#ifdef HAVE_MKSTEMP |
1374 |
if (tmpfd != -1) { |
1375 |
unlink(data->binfile); |
1376 |
close(tmpfd); |
1377 |
} |
1378 |
#endif /* HAVE_MKSTEMP */ |
1346 |
_FP_free (data->binfile); |
1379 |
_FP_free (data->binfile); |
1347 |
data->binfile = NULL; |
1380 |
data->binfile = NULL; |
1348 |
uu_errno = errno; |
1381 |
uu_errno = errno; |
1349 |
return UURET_IOERR; |
1382 |
return UURET_IOERR; |
1350 |
} |
1383 |
} |
|
|
1384 |
|
1351 |
/* |
1385 |
/* |
1352 |
* we don't have begin lines in Base64 or plain text files. |
1386 |
* we don't have begin lines in Base64 or plain text files. |
1353 |
*/ |
1387 |
*/ |
Lines 1496-1502
UUDecode (uulist *data)
Link Here
|
1496 |
*/ |
1530 |
*/ |
1497 |
|
1531 |
|
1498 |
if (data->uudet == BH_ENCODED && data->binfile) { |
1532 |
if (data->uudet == BH_ENCODED && data->binfile) { |
|
|
1533 |
#ifdef HAVE_MKSTEMP |
1534 |
ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
1535 |
|
1536 |
if (ntmp == NULL) { |
1537 |
#else |
1499 |
if ((ntmp = tempnam (NULL, "uu")) == NULL) { |
1538 |
if ((ntmp = tempnam (NULL, "uu")) == NULL) { |
|
|
1539 |
#endif /* HAVE_MKSTEMP */ |
1500 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1540 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1501 |
uustring (S_NO_TEMP_NAME)); |
1541 |
uustring (S_NO_TEMP_NAME)); |
1502 |
progress.action = 0; |
1542 |
progress.action = 0; |
Lines 1510-1524
UUDecode (uulist *data)
Link Here
|
1510 |
free (ntmp); |
1550 |
free (ntmp); |
1511 |
return UURET_IOERR; |
1551 |
return UURET_IOERR; |
1512 |
} |
1552 |
} |
|
|
1553 |
|
1554 |
#ifdef HAVE_MKSTEMP |
1555 |
strcpy(ntmp, tmpdir); |
1556 |
strcat(ntmp, "/"); |
1557 |
strcat(ntmp, tmpprefix); |
1558 |
if ((tmpfd = mkstemp(ntmp)) == -1 || |
1559 |
(dataout = fdopen(tmpfd, "wb")) == NULL) { |
1560 |
#else |
1513 |
if ((dataout = fopen (ntmp, "wb")) == NULL) { |
1561 |
if ((dataout = fopen (ntmp, "wb")) == NULL) { |
|
|
1562 |
#endif /* HAVE_MKSTEMP */ |
1514 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1563 |
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1515 |
uustring (S_NOT_OPEN_TARGET), |
1564 |
uustring (S_NOT_OPEN_TARGET), |
1516 |
ntmp, strerror (uu_errno = errno)); |
1565 |
ntmp, strerror (uu_errno = errno)); |
1517 |
progress.action = 0; |
1566 |
progress.action = 0; |
1518 |
fclose (datain); |
1567 |
fclose (datain); |
|
|
1568 |
#ifdef HAVE_MKSTEMP |
1569 |
if (tmpfd != -1) { |
1570 |
unlink(ntmp); |
1571 |
close(tmpfd); |
1572 |
} |
1573 |
#endif /* HAVE_MKSTEMP */ |
1519 |
free (ntmp); |
1574 |
free (ntmp); |
1520 |
return UURET_IOERR; |
1575 |
return UURET_IOERR; |
1521 |
} |
1576 |
} |
|
|
1577 |
|
1522 |
/* |
1578 |
/* |
1523 |
* read fork lengths. remember they're in Motorola format |
1579 |
* read fork lengths. remember they're in Motorola format |
1524 |
*/ |
1580 |
*/ |