diff --git a/apps/app_sayunixtime.c b/apps/app_sayunixtime.c
index d3efc010111533ee327faf2855a97cbc19ece238..09ba838f9402a893b25b7e0dcf2dccf04af492f4 100644
--- a/apps/app_sayunixtime.c
+++ b/apps/app_sayunixtime.c
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (c) 2003 Tilghman Lesher.  All rights reserved.
+ * Copyright (c) 2003, 2006 Tilghman Lesher.  All rights reserved.
  * Copyright (c) 2006 Digium, Inc.
  *
  * Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>
@@ -93,7 +93,7 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data)
 
 	AST_STANDARD_APP_ARGS(args, parse);
 
-	ast_get_time_t(args.timeval, &unixtime, time(NULL));
+	ast_get_time_t(args.timeval, &unixtime, time(NULL), NULL);
 
 	if (chan->_state != AST_STATE_UP)
 		res = ast_answer(chan);
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 7b9a37dfd7cdd3be5819424b98f6efd896b1dacc..dc2db6e0be37ae15b13a71671472058377c6f65a 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3607,7 +3607,7 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
 	struct vm_zone *the_zone = NULL;
 	time_t t;
 
-	if (ast_get_time_t(origtime, &t, 0)) {
+	if (ast_get_time_t(origtime, &t, 0, NULL)) {
 		ast_log(LOG_WARNING, "Couldn't find origtime in %s\n", filename);
 		return 0;
 	}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index df647b63de49e87d7d89d0659a2e2d542704bbb2..f6a197783750cab9f996668ac0235eabd2e6e4a2 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -2617,7 +2617,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
 				break;
 			} 
 		} else if (!strcasecmp(tmp->name, "regseconds")) {
-			ast_get_time_t(tmp->value, &regseconds, 0);
+			ast_get_time_t(tmp->value, &regseconds, 0, NULL);
 		} else if (!strcasecmp(tmp->name, "ipaddr")) {
 			inet_aton(tmp->value, &(peer->addr.sin_addr));
 		} else if (!strcasecmp(tmp->name, "port")) {
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index e56f4d2d8e136bfef8d0026a0a6bd9cf01872640..b2f80d6bb021064431925d88c3665a442ddbac5d 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  * 
- * Copyright (C) 2004, Christian Richter
+ * Copyright (C) 2004 - 2006, Christian Richter
  *
  * Christian Richter <crich@beronet.com>
  *
@@ -2933,7 +2933,7 @@ static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc) {
 
 void import_ies(struct ast_channel *chan, struct misdn_bchannel *bc)
 {
-	char *tmp;
+	const char *tmp;
 
 	tmp=pbx_builtin_getvar_helper(chan,"PRI_MODE");
 	if (tmp) bc->mode=atoi(tmp);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index bf11e57905a452f75e2499083a020554d32494ad..848422fd31d9eb4ce9e40a63b61e2c3dc263f0e7 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -12149,7 +12149,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
 			continue;
 
 		if (realtime && !strcasecmp(v->name, "regseconds")) {
-			ast_get_time_t(v->value, &regseconds, 0);
+			ast_get_time_t(v->value, &regseconds, 0, NULL);
 		} else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) {
 			inet_aton(v->value, &(peer->addr.sin_addr));
 		} else if (realtime && !strcasecmp(v->name, "name"))
diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c
index c6c1dfacf5a339f25ae73d613cafcb724b783a1b..a43a1f4988e7229189f2ae2a61ecb2a8205a38bc 100644
--- a/channels/chan_vpb.c
+++ b/channels/chan_vpb.c
@@ -149,7 +149,9 @@ static VPB_TONE Ringbacktone = {440, 480,   0, -20,   -20, -100,  2000, 4000};
 #endif
 
 /* grunt tone defn's */
+#if 0
 static VPB_DETECT toned_grunt = { 3, VPB_GRUNT, 1, 2000, 3000, 0, 0, -40, 0, 0, 0, 40, { { VPB_DELAY, 1000, 0, 0 }, { VPB_RISING, 0, 40, 0 }, { 0, 100, 0, 0 } } };
+#endif
 static VPB_DETECT toned_ungrunt = { 2, VPB_GRUNT, 1, 2000, 1, 0, 0, -40, 0, 0, 30, 40, { { 0, 0, 0, 0 } } };
 
 /* Use loop polarity detection for CID */
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index e24fc1ea49fe1acebc4f592af9ea6848c7f3e4d5..26712f8d51f273199c5a9502766d135f7ca5f363 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -245,7 +245,7 @@ static int acf_strftime(struct ast_channel *chan, char *cmd, char *parse,
 
 	AST_STANDARD_APP_ARGS(args, parse);
 
-	ast_get_time_t(args.epoch, &epochi, time(NULL));
+	ast_get_time_t(args.epoch, &epochi, time(NULL), NULL);
 	ast_localtime(&epochi, &tm, args.timezone);
 
 	if (!args.format)
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index a48520ad60d77a8ee543a10a903b30ecc5582200..c9015544a9e13273488186af16afe6ab85f951e6 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -228,9 +228,10 @@ void ast_join(char *s, size_t len, char * const w[]);
   \param src String to parse
   \param dst Destination
   \param _default Value to use if the string does not contain a valid time
+  \param consumed The number of characters 'consumed' in the string by the parse (see 'man sscanf' for details)
   \return zero on success, non-zero on failure
 */
-int ast_get_time_t(const char *src, time_t *dst, time_t _default);
+int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed);
 
 /* The realloca lets us ast_restrdupa(), but you can't mix any other ast_strdup calls! */
 
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 9d842c69b052b840be5fe0de2f91fff766fc2728..0a79b5cd9bc0ea08d75ec5fcca9079dd6345d6d6 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -1132,16 +1132,15 @@ static int cache_lookup_internal(time_t now, struct dundi_request *req, char *ke
 	int expiration;
 	char fs[256];
 	time_t timeout;
-	unsigned int x;
+
 	/* Build request string */
 	if (!ast_db_get("dundi/cache", key, data, sizeof(data))) {
 		ptr = data;
-		if (sscanf(ptr, "%d|%n", (int *)&x, &length) == 1) {
-			timeout = x;
+		if (!ast_get_time_t(ptr, &timeout, 0, &length)) {
 			expiration = timeout - now;
 			if (expiration > 0) {
 				ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", (int)(timeout - now));
-				ptr += length;
+				ptr += length + 1;
 				while((sscanf(ptr, "%d/%d/%d/%n", &(flags.flags), &weight, &tech, &length) == 3)) {
 					ptr += length;
 					term = strchr(ptr, '|');
@@ -2030,11 +2029,9 @@ static void load_password(void)
 	char *last=NULL;
 	char tmp[256];
 	time_t expired;
-	unsigned int x;
 	
 	ast_db_get(secretpath, "secretexpiry", tmp, sizeof(tmp));
-	if (sscanf(tmp, "%d", (int *)&x) == 1) {
-		expired = x;
+	if (!ast_get_time_t(tmp, &expired, 0, NULL)) {
 		ast_db_get(secretpath, "secret", tmp, sizeof(tmp));
 		current = strchr(tmp, ';');
 		if (!current)
diff --git a/res/res_agi.c b/res/res_agi.c
index 5a2e5cc1f0872d13ca9d17b427592cf179a80b89..874eb49b8f454d9c31b343055ddda6f97fe887b0 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -770,7 +770,7 @@ static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char
 	if (argc > 5 && !ast_strlen_zero(argv[5]))
 		zone = argv[5];
 
-	if (ast_get_time_t(argv[2], &unixtime, 0))
+	if (ast_get_time_t(argv[2], &unixtime, 0, NULL))
 		return RESULT_SHOWUSAGE;
 
 	res = ast_say_date_with_format(chan, unixtime, argv[3], chan->language, format, zone);
diff --git a/utils.c b/utils.c
index 23c23929593f44a8648c589c12f34cb7cbf7660d..ac2d11ba91d23d763d8062e8f1e7a32bdd6f3826 100644
--- a/utils.c
+++ b/utils.c
@@ -1051,9 +1051,10 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
 /*
  * get values from config variables.
  */
-int ast_get_time_t(const char *src, time_t *dst, time_t _default)
+int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
 {
 	long t;
+	int scanned;
 
 	if (dst == NULL)
 		return -1;
@@ -1064,8 +1065,10 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default)
 		return -1;
 
 	/* only integer at the moment, but one day we could accept more formats */
-	if (sscanf(src, "%ld", &t) == 1) {
+	if (sscanf(src, "%ld%n", &t, &scanned) == 1) {
 		*dst = t;
+		if (consumed)
+			*consumed = scanned;
 		return 0;
 	} else
 		return -1;