diff mbox

[5/7] Add handling of too long arguments.

Message ID 1361176668-22661-6-git-send-email-eric@regit.org
State Accepted
Headers show

Commit Message

Eric Leblond Feb. 18, 2013, 8:37 a.m. UTC
When an argument is too long, it can not be store into ulogd
configuration and this must results in a error.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 include/ulogd/conffile.h |    1 +
 src/conffile.c           |    5 ++++-
 src/ulogd.c              |    5 +++++
 3 files changed, 10 insertions(+), 1 deletion(-)

Comments

Mr Dash Four Feb. 18, 2013, 9:41 a.m. UTC | #1
> +				"too long string value for key \"%s\"\n",
>   
"string value too long for key"
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Leblond Feb. 18, 2013, 3:04 p.m. UTC | #2
Hi,

On Mon, 2013-02-18 at 09:41 +0000, Mr Dash Four wrote:
> > +				"too long string value for key \"%s\"\n",
> >   
> "string value too long for key"

Thanks a lot. Fixing this and the other one!

BR,
diff mbox

Patch

diff --git a/include/ulogd/conffile.h b/include/ulogd/conffile.h
index 0b8ac0e..69a6f70 100644
--- a/include/ulogd/conffile.h
+++ b/include/ulogd/conffile.h
@@ -18,6 +18,7 @@  enum {
 	ERRMAND,	/* mandatory option not found */
 	ERRUNKN,	/* unknown config key */
 	ERRSECTION,	/* section not found */
+	ERRTOOLONG,	/* string too long */
 };
 
 /* maximum line length of config file entries */
diff --git a/src/conffile.c b/src/conffile.c
index 616d7a9..9a73406 100644
--- a/src/conffile.c
+++ b/src/conffile.c
@@ -197,7 +197,10 @@  int config_parse_file(const char *section, struct config_keyset *kset)
 					if (strlen(args) < 
 					    CONFIG_VAL_STRING_LEN ) {
 						strcpy(ce->u.string, args);
-						/* FIXME: what if not ? */
+					} else {
+						config_errce = ce;
+						err = -ERRTOOLONG;
+						goto cpf_error;
 					}
 					break;
 				case CONFIG_TYPE_INT:
diff --git a/src/ulogd.c b/src/ulogd.c
index f8c8ed0..6c0df8a 100644
--- a/src/ulogd.c
+++ b/src/ulogd.c
@@ -989,6 +989,11 @@  static int parse_conffile(const char *section, struct config_keyset *ce)
 			ulogd_log(ULOGD_ERROR,
 				"section \"%s\" not found\n", section);
 			break;
+		case -ERRTOOLONG:
+			ulogd_log(ULOGD_ERROR,
+				"too long string value for key \"%s\"\n",
+				config_errce->key);
+			break;
 	}
 	return 1;
 }