Mercurial > hg > toybox
diff toys.h @ 1342:3b85d2ce34aa draft
When locale is enabled, sprintf("%.123s", str) is counting characters, not bytes, so we can't globally enable locale without opening stack/heap smashing vulnerabilities. Make commands individually request setlocale() using TOYFLAGS instead.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 09 Jun 2014 05:51:04 -0500 |
parents | 313980d3d78c |
children | d1411369baa7 |
line wrap: on
line diff
--- a/toys.h Sun Jun 08 17:05:10 2014 -0500 +++ b/toys.h Mon Jun 09 05:51:04 2014 -0500 @@ -105,6 +105,10 @@ #define TOYFLAG_NEEDROOT (1<<7) #define TOYFLAG_ROOTONLY (TOYFLAG_STAYROOT|TOYFLAG_NEEDROOT) +// Call setlocale to listen to environment variables. +// This invalidates sprintf("%.*s", size, string) as a valid length constraint. +#define TOYFLAG_LOCALE (1<<8) + // Array of available commands extern struct toy_list {