mirror of https://github.com/mgba-emu/mgba.git
Test: I added strlcpy for a reason
This commit is contained in:
parent
79d2e95d02
commit
3795a64b77
|
@ -11,6 +11,7 @@
|
||||||
#include <mgba/feature/video-logger.h>
|
#include <mgba/feature/video-logger.h>
|
||||||
|
|
||||||
#include <mgba-util/png-io.h>
|
#include <mgba-util/png-io.h>
|
||||||
|
#include <mgba-util/string.h>
|
||||||
#include <mgba-util/table.h>
|
#include <mgba-util/table.h>
|
||||||
#include <mgba-util/vector.h>
|
#include <mgba-util/vector.h>
|
||||||
#include <mgba-util/vfs.h>
|
#include <mgba-util/vfs.h>
|
||||||
|
@ -127,7 +128,7 @@ static bool parseCInemaArgs(int argc, char* const* argv) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
strncpy(base, optarg, sizeof(base));
|
strlcpy(base, optarg, sizeof(base));
|
||||||
// TODO: Verify path exists
|
// TODO: Verify path exists
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -140,7 +141,7 @@ static bool parseCInemaArgs(int argc, char* const* argv) {
|
||||||
dryRun = true;
|
dryRun = true;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
strncpy(outdir, optarg, sizeof(outdir));
|
strlcpy(outdir, optarg, sizeof(outdir));
|
||||||
// TODO: Make directory
|
// TODO: Make directory
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
|
@ -244,7 +245,7 @@ static void reduceTestList(struct CInemaTestList* tests) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testToPath(const char* testName, char* path) {
|
static void testToPath(const char* testName, char* path) {
|
||||||
strncpy(path, base, PATH_MAX);
|
strlcpy(path, base, PATH_MAX);
|
||||||
|
|
||||||
bool dotSeen = true;
|
bool dotSeen = true;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -253,7 +254,7 @@ static void testToPath(const char* testName, char* path) {
|
||||||
dotSeen = true;
|
dotSeen = true;
|
||||||
} else {
|
} else {
|
||||||
if (dotSeen) {
|
if (dotSeen) {
|
||||||
strncpy(&path[i], PATH_SEP, PATH_MAX - i);
|
strlcpy(&path[i], PATH_SEP, PATH_MAX - i);
|
||||||
i += strlen(PATH_SEP);
|
i += strlen(PATH_SEP);
|
||||||
dotSeen = false;
|
dotSeen = false;
|
||||||
if (!i) {
|
if (!i) {
|
||||||
|
@ -268,7 +269,7 @@ static void testToPath(const char* testName, char* path) {
|
||||||
|
|
||||||
static void _loadConfigTree(struct Table* configTree, const char* testName) {
|
static void _loadConfigTree(struct Table* configTree, const char* testName) {
|
||||||
char key[MAX_TEST];
|
char key[MAX_TEST];
|
||||||
strncpy(key, testName, sizeof(key) - 1);
|
strlcpy(key, testName, sizeof(key));
|
||||||
|
|
||||||
struct mCoreConfig* config;
|
struct mCoreConfig* config;
|
||||||
while (!(config = HashTableLookup(configTree, key))) {
|
while (!(config = HashTableLookup(configTree, key))) {
|
||||||
|
@ -301,7 +302,7 @@ static const char* _lookupValue(struct Table* configTree, const char* testName,
|
||||||
_loadConfigTree(configTree, testName);
|
_loadConfigTree(configTree, testName);
|
||||||
|
|
||||||
char testKey[MAX_TEST];
|
char testKey[MAX_TEST];
|
||||||
strncpy(testKey, testName, sizeof(testKey) - 1);
|
strlcpy(testKey, testName, sizeof(testKey));
|
||||||
|
|
||||||
struct mCoreConfig* config;
|
struct mCoreConfig* config;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -378,10 +379,10 @@ bool CInemaTestInit(struct CInemaTest* test, const char* directory, const char*
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memset(test, 0, sizeof(*test));
|
memset(test, 0, sizeof(*test));
|
||||||
strncpy(test->directory, directory, sizeof(test->directory) - 1);
|
strlcpy(test->directory, directory, sizeof(test->directory));
|
||||||
strncpy(test->filename, filename, sizeof(test->filename) - 1);
|
strlcpy(test->filename, filename, sizeof(test->filename));
|
||||||
directory += strlen(base) + 1;
|
directory += strlen(base) + 1;
|
||||||
strncpy(test->name, directory, sizeof(test->name) - 1);
|
strlcpy(test->name, directory, sizeof(test->name));
|
||||||
char* str = strstr(test->name, PATH_SEP);
|
char* str = strstr(test->name, PATH_SEP);
|
||||||
while (str) {
|
while (str) {
|
||||||
str[0] = '.';
|
str[0] = '.';
|
||||||
|
@ -446,7 +447,7 @@ static bool _loadBaseline(struct VDir* dir, struct CInemaImage* image, size_t fr
|
||||||
|
|
||||||
static struct VDir* _makeOutDir(const char* testName) {
|
static struct VDir* _makeOutDir(const char* testName) {
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
strncpy(path, outdir, sizeof(path) - 1);
|
strlcpy(path, outdir, sizeof(path));
|
||||||
char* pathEnd = path + strlen(path);
|
char* pathEnd = path + strlen(path);
|
||||||
const char* pos;
|
const char* pos;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -768,7 +769,7 @@ int main(int argc, char** argv) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
char* rbase = realpath(base, NULL);
|
char* rbase = realpath(base, NULL);
|
||||||
if (rbase) {
|
if (rbase) {
|
||||||
strncpy(base, rbase, PATH_MAX);
|
strlcpy(base, rbase, sizeof(base));
|
||||||
free(rbase);
|
free(rbase);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue