Bug#697350: Patch for the problem <erfolgreich auf Virenfreiheit geprueft>
Hello,
Thomas Renard, le Fri 04 Jan 2013 13:30:48 +0100, a écrit :
> This patch works for me: Adjust the length of the parameter string copy
> by 1 though that is not very neat because of (again) fixed string length...
Indeed. Could you try the attached patch instead? It'll still be a
fixed string length, but at least it will be the currently-allowed
maximum.
Samuel
diff --git a/eBook-speaker.c b/eBook-speaker.c
index aa18d9d..2fce0eb 100644
--- a/eBook-speaker.c
+++ b/eBook-speaker.c
@@ -1320,9 +1320,9 @@ void read_rc ()
p += 9;
while (*p == ' ' || *p == '\t' || *p == '\n')
p++;
- strncpy (dc_language, p, 5);
+ strncpy (dc_language, p, sizeof(dc_language));
p = dc_language;
- while (*p != ' ' && *p != '\t' && *p != 0)
+ while (*p != ' ' && *p != '\t' && *p != 0 && p < dc_language+sizeof(dc_language)-1)
p++;
*p = 0;
} // if
@@ -1949,7 +1949,8 @@ void set_language ()
fflush (stdout);
exit (1);
} // if
- strncpy (dc_language, label, 5);
+ strncpy (dc_language, label, sizeof(dc_language)-1);
+ dc_languages[sizeof(dc_language)-1] = 0;
zip_fclose (opf);
} // set_language
@@ -1984,7 +1985,8 @@ int main (int argc, char *argv[])
switch (opt)
{
case 'l':
- strncpy (dc_language, optarg, 5);
+ strncpy (dc_language, optarg, sizeof(dc_language)-1);
+ dc_language[sizeof(dc_language)-1] = 0;
break;
default:
usage (prog_name);
Reply to: