gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnokii] 02/02: Throw an error if parameter "model" or "port" is too lon


From: Daniele Forsi
Subject: [gnokii] 02/02: Throw an error if parameter "model" or "port" is too long
Date: Sun, 06 Jul 2014 10:06:19 +0000

dforsi pushed a commit to branch master
in repository gnokii.

commit d792885a884806e1c4034b63f79d29e7796d7a07
Author: Daniele Forsi <address@hidden>
Date:   Sun Jul 6 11:58:53 2014 +0200

    Throw an error if parameter "model" or "port" is too long
    
    Closes http://savannah.nongnu.org/bugs/?42680 with WONTFIX.
---
 ChangeLog          |    3 +++
 common/cfgreader.c |   18 ++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1585de1..d731419 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,9 @@
     o add GN_OP_Passthrough                         (Daniele Forsi)
     o add id for Nokia C1-02 to misc.c only; use model=series40
       partially supported because it's a 6th Edition phone   (GDR!)
+    o return GN_ERR_ENTRYTOOLONG if model or port in gnokiirc is
+      too long; closes http://savannah.nongnu.org/bugs/?42680
+                                                    (Daniele Forsi)
  * at driver updates
     o in the default case autodetect if PDU SMS starts with SMSC
                                                     (Daniele Forsi)
diff --git a/common/cfgreader.c b/common/cfgreader.c
index 52da747..abf2ae4 100644
--- a/common/cfgreader.c
+++ b/common/cfgreader.c
@@ -723,14 +723,22 @@ static gn_error cfg_psection_load(gn_config *cfg, const 
char *section, const gn_
        if (!(val = gn_cfg_get(gn_cfg_info, section, "model"))) {
                fprintf(stderr, _("You need to define '%s' in the config 
file.\n"), "model");
                return GN_ERR_NOMODEL;
-       } else
-               snprintf(cfg->model, sizeof(cfg->model), "%s", val);
+       } else {
+               if (snprintf(cfg->model, sizeof(cfg->model), "%s", val) >= 
sizeof(cfg->model)) {
+                       fprintf(stderr, _("Unsupported [%s] %s value 
\"%s\"\n"), section, "model", val);
+                       return GN_ERR_ENTRYTOOLONG;
+               }
+       }
 
        if (!(val = gn_cfg_get(gn_cfg_info, section, "port"))) {
                fprintf(stderr, _("You need to define '%s' in the config 
file.\n"), "port");
                return GN_ERR_NOPORT;
-       } else
-               snprintf(cfg->port_device, sizeof(cfg->port_device), "%s", val);
+       } else {
+               if (snprintf(cfg->port_device, sizeof(cfg->port_device), "%s", 
val) >= sizeof(cfg->port_device)) {
+                       fprintf(stderr, _("Unsupported [%s] %s value 
\"%s\"\n"), section, "port", val);
+                       return GN_ERR_ENTRYTOOLONG;
+               }
+       }
 
        if (!(val = gn_cfg_get(gn_cfg_info, section, "connection"))) {
                fprintf(stderr, _("You need to define '%s' in the config 
file.\n"), "connection");
@@ -741,6 +749,8 @@ static gn_error cfg_psection_load(gn_config *cfg, const 
char *section, const gn_
                        fprintf(stderr, _("Unsupported [%s] %s value 
\"%s\"\n"), section, "connection", val);
                        return GN_ERR_NOCONNECTION;
                }
+               if (!strcmp("pcsc", val))
+                       fprintf(stderr, "WARNING: %s=%s is deprecated and will 
soon be removed. Use %s=%s instead.\n", "connection", val, "connection", 
"libpcsclite");
        }
 
        if (!(val = gn_cfg_get(gn_cfg_info, section, "initlength")))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]