Merge branch 'master' into develop

Conflicts:
	src/kernel/save.test.c
	src/kernel/version.h
This commit is contained in:
Enno Rehling 2016-05-20 23:04:46 +02:00
commit c1b0395a6c
4 changed files with 24 additions and 13 deletions

View File

@ -1203,15 +1203,14 @@ static char * getpasswd(int fno) {
static void read_password(gamedata *data, faction *f) {
char name[128];
READ_STR(data->store, name, sizeof(name));
if (data->version == BADCRYPT_VERSION) {
if (name[0]=='$' && data->version == BADCRYPT_VERSION) {
char * pass = getpasswd(f->no);
if (pass) {
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
free(pass); // TODO: remove this allocation!
}
else {
free(f->_password);
f->_password = NULL;
log_error("data version is BADCRYPT but %s not in password.txt", itoa36(f->no));
}
}
else {

View File

@ -285,20 +285,25 @@ static void test_read_password_external(CuTest *tc) {
CuAssertPtrNotNull(tc, f->_password);
mstream_init(&data.strm);
gamedata_init(&data, &store, RELEASE_VERSION);
WRITE_TOK(data.store, (const char *)f->_password);
WRITE_TOK(data.store, (const char *)f->_password);
WRITE_TOK(data.store, "newpassword");
WRITE_TOK(data.store, "secret");
WRITE_TOK(data.store, "$brokenhash");
data.strm.api->rewind(data.strm.handle);
data.version = NOCRYPT_VERSION;
_test_read_password(&data, f);
CuAssertStrEquals(tc, "newpassword", f->_password);
data.version = BADCRYPT_VERSION;
_test_read_password(&data, f);
CuAssertPtrEquals(tc, 0, f->_password);
CuAssertStrEquals(tc, "secret", f->_password);
F = fopen(pwfile, "wt");
fprintf(F, "%s:secret\n", itoa36(f->no));
fprintf(F, "%s:pwfile\n", itoa36(f->no));
fclose(F);
CuAssertTrue(tc, checkpasswd(f, "secret"));
_test_read_password(&data, f);
CuAssertPtrNotNull(tc, f->_password);
CuAssertStrEquals(tc, "pwfile", f->_password);
CuAssertTrue(tc, checkpasswd(f, "pwfile"));
mstream_done(&data.strm);
gamedata_done(&data);
CuAssertTrue(tc, checkpasswd(f, "secret"));
CuAssertIntEquals(tc, 0, remove(pwfile));
}

View File

@ -33,10 +33,15 @@
#define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */
#define OWNER_3_VERSION 349 /* regions store last owner, not last alliance */
#define ATTRIBOWNER_VERSION 351 /* all attrib_type functions know who owns the attribute */
#define BADCRYPT_VERSION 351 /* passwords are encrypted, poorly */
#define ATHASH_VERSION 352 /* attribute-type hash, not name */
#define NOWATCH_VERSION 353 /* plane->watchers is gone */
#define CRYPT_VERSION 354 /* passwords are encrypted */
#define BADCRYPT_VERSION 351 /* passwords are broken, 969.dat only. */
#define NOCRYPT_VERSION 352 /* passwords are plaintext again */
#define ATHASH_VERSION 353 /* attribute-type hash, not name */
#define NOWATCH_VERSION 354 /* plane->watchers is gone */
/* unfinished: */
#define CRYPT_VERSION 400 /* passwords are encrypted */
#define RELEASE_VERSION NOWATCH_VERSION /* current datafile */
#define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
#define STREAM_VERSION 2 /* internal encoding of binary files */

View File

@ -5,7 +5,9 @@ CD ..
SET ERESSEA=%CD%
CD %SRCDIR%
IF exist build-vs%VSVERSION% goto HAVEDIR
mkdir build-vs%VSVERSION%
:HAVEDIR
cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
PAUSE