string length limit in .CFG is 255 chars

This commit is contained in:
Thomas Bernard 2019-01-18 13:00:59 +01:00
parent a5d2dfab79
commit a95b7504a6
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -2276,10 +2276,13 @@ int Save_CFG(void)
Chunk.Size=0; Chunk.Size=0;
for (i=0; i<10; i++) for (i=0; i<10; i++)
{ {
if (Bound_script[i]==NULL)
Chunk.Size += 1; Chunk.Size += 1;
else if (Bound_script[i] != NULL)
Chunk.Size+=strlen(Bound_script[i])+1; {
size_t len = strlen(Bound_script[i]);
if (len < 256)
Chunk.Size += (word)len;
}
} }
// Header // Header
if (!Write_byte(Handle, Chunk.Number) || if (!Write_byte(Handle, Chunk.Number) ||
@ -2291,7 +2294,13 @@ int Save_CFG(void)
{ {
byte size=0; byte size=0;
if (Bound_script[i] != NULL) if (Bound_script[i] != NULL)
size=strlen(Bound_script[i]); {
size_t len = strlen(Bound_script[i]);
if (len < 256)
size = (byte)len;
else
GFX2_Log(GFX2_WARNING, "Cannot save script path (%lu > 255 characters)\n", (unsigned long)len);
}
if (!Write_byte(Handle, size)) if (!Write_byte(Handle, size))
goto Erreur_sauvegarde_config; goto Erreur_sauvegarde_config;