Commit 3062d1cd authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Don't call strlen(nullptr) in mkdtemp and mkstemp

Summary: Because it's a terrible idea. It also didn't work.

Reviewed By: yfeldblum

Differential Revision: D3711443

fbshipit-source-id: 48ab77dfff005347c72daeaf0d27390bb86f4bd1
parent e8308aaf
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <cstring> #include <cstring>
#include <errno.h> #include <errno.h>
#include <folly/portability/Fcntl.h> #include <folly/portability/Fcntl.h>
#include <folly/portability/SysStat.h> #include <folly/portability/SysStat.h>
#include <folly/portability/Windows.h> #include <folly/portability/Windows.h>
...@@ -31,7 +32,7 @@ char* mktemp(char* tn) { return _mktemp(tn); } ...@@ -31,7 +32,7 @@ char* mktemp(char* tn) { return _mktemp(tn); }
// still working just fine. // still working just fine.
char* mkdtemp(char* tn) { char* mkdtemp(char* tn) {
char* ptr = nullptr; char* ptr = nullptr;
auto len = strlen(ptr); auto len = strlen(tn);
int ret = 0; int ret = 0;
do { do {
strcpy(tn + len - 6, "XXXXXX"); strcpy(tn + len - 6, "XXXXXX");
...@@ -49,7 +50,7 @@ char* mkdtemp(char* tn) { ...@@ -49,7 +50,7 @@ char* mkdtemp(char* tn) {
int mkstemp(char* tn) { int mkstemp(char* tn) {
char* ptr = nullptr; char* ptr = nullptr;
auto len = strlen(ptr); auto len = strlen(tn);
int ret = 0; int ret = 0;
do { do {
strcpy(tn + len - 6, "XXXXXX"); strcpy(tn + len - 6, "XXXXXX");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment