summaryrefslogtreecommitdiff
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
authorMike Frysinger2006-12-30 19:43:35 +0000
committerMike Frysinger2006-12-30 19:43:35 +0000
commit68ffb9a85da9884880eed8ca2dab6ebf6c78729d (patch)
treecabac94fa14a9e8e14bcf420731edccc59698820 /scripts/kconfig/confdata.c
parent40ae9b56174513c9e843f7b479bc64e14b2f1b64 (diff)
downloadbusybox-68ffb9a85da9884880eed8ca2dab6ebf6c78729d.zip
busybox-68ffb9a85da9884880eed8ca2dab6ebf6c78729d.tar.gz
make sure AUTOCONF_TIMESTAMP is filled up properly ... if user has a timezone of Factory for example, strftime() will overflow the string and leave us without a trailing "\n and all hell breaks loose when we compile
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index d38bbba..b4c862a 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -395,9 +395,18 @@ int conf_write(const char *name)
char buf[sizeof("#define AUTOCONF_TIMESTAMP "
"\"YYYY-MM-DD HH:MM:SS some_timezone\"\n")];
buf[0] = '\0';
- if (use_timestamp)
- strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP "
- "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now));
+ if (use_timestamp) {
+ size_t ret = \
+ strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP "
+ "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now));
+ /* if user has Factory timezone or some other odd install, the
+ * %Z above will overflow the string leaving us with undefined
+ * results ... so let's try again without the timezone.
+ */
+ if (ret == 0)
+ strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP "
+ "\"%Y-%m-%d %H:%M:%S\"\n", localtime(&now));
+ }
fprintf(out_h, "/*\n"
" * Automatically generated C config: don't edit\n"
" * Linux kernel version: %s\n"