1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-01 11:26:52 +03:00

sample: Fix a possible buffer overrun.

This commit is contained in:
Andreas Schneider
2013-06-17 13:27:40 +02:00
parent 7ceaea479e
commit 59dcebd604

View File

@ -60,9 +60,12 @@ struct ssh_callbacks_struct cb = {
static void add_cmd(char *cmd){ static void add_cmd(char *cmd){
int n; 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; return;
}
cmds[n]=strdup(cmd); cmds[n]=strdup(cmd);
} }