aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-06-17 13:27:40 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-06-17 13:27:40 +0200
commit59dcebd60424ee3f0a7c1cca1d661d5e982b48b3 (patch)
tree8ded22d2b988d78021552d65e3ada1e7eec8757d /examples
parent7ceaea479eeac0bf73c4a3482fed1230f63c4e47 (diff)
downloadlibssh-59dcebd60424ee3f0a7c1cca1d661d5e982b48b3.tar.gz
libssh-59dcebd60424ee3f0a7c1cca1d661d5e982b48b3.tar.xz
libssh-59dcebd60424ee3f0a7c1cca1d661d5e982b48b3.zip
sample: Fix a possible buffer overrun.
Diffstat (limited to 'examples')
-rw-r--r--examples/sample.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/sample.c b/examples/sample.c
index cfe4b3a6..93634d80 100644
--- a/examples/sample.c
+++ b/examples/sample.c
@@ -60,9 +60,12 @@ struct ssh_callbacks_struct cb = {
static void add_cmd(char *cmd){
int n;
- for(n=0;cmds[n] && (n<MAXCMD);n++);
- if(n==MAXCMD)
+
+ for (n = 0; (n < MAXCMD) && cmds[n] != NULL; n++);
+
+ if (n == MAXCMD) {
return;
+ }
cmds[n]=strdup(cmd);
}