diff options
| author | Raghavendra G <rgowdapp@redhat.com> | 2016-05-06 12:26:29 +0530 | 
|---|---|---|
| committer | Raghavendra G <rgowdapp@redhat.com> | 2016-08-25 05:18:09 -0700 | 
| commit | c68b561f048a02f479819b1c9cb3b5b896db18a6 (patch) | |
| tree | 08ebde402edbeab8af553d786ff70f112ba8e0ef /libglusterfs | |
| parent | afabb66f36b75db4d5aee46e694990b63f454133 (diff) | |
quotad: fix potential buffer overflows
This converts sprintf to gf_asprintf in following components:                                                                                                          * quotad.c
* dht
* afr
* protocol/client
* rpc/rpc-lib
* rpc/rpc-transport
Change-Id: If8a267bab3d91003bdef3a92664077a0136745ee
BUG: 1332073
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: http://review.gluster.org/14102
Tested-by: Manikandan Selvaganesh <mselvaga@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com>
Diffstat (limited to 'libglusterfs')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 11 | ||||
| -rw-r--r-- | libglusterfs/src/graph.c | 9 | 
2 files changed, 14 insertions, 6 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 311ed72d04c..8dc5141247e 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -668,9 +668,14 @@ gf_dump_config_flags ()  /* Define to the full name and version of this package. */  #ifdef PACKAGE_STRING          { -                char msg[128]; -                sprintf (msg, "package-string: %s", PACKAGE_STRING); -                gf_msg_plain_nomem (GF_LOG_ALERT, msg); +                char *msg = NULL; +                int   ret = -1; + +                ret = gf_asprintf (&msg, "package-string: %s", PACKAGE_STRING); +                if (ret >= 0) { +                        gf_msg_plain_nomem (GF_LOG_ALERT, msg); +                        GF_FREE (msg); +                }          }  #endif diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index 2e290bb20a1..04bb92c7c75 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -598,16 +598,19 @@ _glusterfs_reachable_leaves(xlator_t *base, xlator_t *xl, dict_t *leaves)          xlator_list_t *list = NULL;          int err = 1;          int pos = 0; -        char strpos[6]; +        char *strpos = NULL;          if (glusterfs_is_leaf(xl)) {                  pos = glusterfs_leaf_position(xl);                  if (pos < 0)                          goto out; -                sprintf(strpos, "%d", pos); -                err = dict_set_static_ptr(leaves, strpos, base); +                err = gf_asprintf(&strpos, "%d", pos); +                if (err >= 0) { +                        err = dict_set_static_ptr(leaves, strpos, base); +                        GF_FREE (strpos); +                }          } else {                  for (err = 0, list = xl->children;                       !err && list;  | 
