--- libaitcli/src/telnet.c 2011/03/16 18:28:06 1.1.2.1 +++ libaitcli/src/telnet.c 2012/05/23 15:04:11 1.2.2.1 @@ -3,9 +3,46 @@ * by Michael Pounov * * $Author: misho $ -* $Id: telnet.c,v 1.1.2.1 2011/03/16 18:28:06 misho Exp $ +* $Id: telnet.c,v 1.2.2.1 2012/05/23 15:04:11 misho Exp $ * -*************************************************************************/ +************************************************************************** +The ELWIX and AITNET software is distributed under the following +terms: + +All of the documentation and software included in the ELWIX and AITNET +Releases is copyrighted by ELWIX - Sofia/Bulgaria + +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + by Michael Pounov . All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: +This product includes software developed by Michael Pounov +ELWIX - Embedded LightWeight unIX and its contributors. +4. Neither the name of AITNET nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +*/ #ifndef NDEBUG #define TELOPTS #define TELCMDS @@ -100,7 +137,7 @@ cli_telnetRecv(int sock, struct telnetAttrs **attr, in ta.ta_cmd = buf[i]; if (SB > ta.ta_cmd) { (*nAttr)++; - *attr = realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); + *attr = io_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); if (!*attr) { LOGERR; return -1; @@ -130,7 +167,7 @@ cmd_exit: ta.ta_opt = buf[i]; if (SB != ta.ta_cmd) { (*nAttr)++; - *attr = realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); + *attr = io_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); if (!*attr) { LOGERR; return -1; @@ -155,7 +192,7 @@ opt_exit: ta.ta_sub[ta.ta_sublen] = 0; (*nAttr)++; - *attr = realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); + *attr = io_realloc(*attr, sizeof(struct telnetAttrs) * *nAttr); if (!*attr) { LOGERR; return -1; @@ -166,7 +203,7 @@ opt_exit: ta.ta_sub[ta.ta_sublen++] = buf[i]; } else { cli_SetErr(EPROTONOSUPPORT, "Protocol limitation in sub-option to %d!", MAX_SUB_LEN); - free(*attr); + io_free(*attr); *nAttr = 0; return -1; } @@ -229,7 +266,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int } } - buf = realloc(buf, pos + len); + buf = io_realloc(buf, pos + len); if (!buf) { LOGERR; return -1; @@ -253,7 +290,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int /* add data */ if (data && datLen) { - buf = realloc(buf, pos + datLen); + buf = io_realloc(buf, pos + datLen); if (!buf) { LOGERR; return -1; @@ -266,7 +303,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int /* add GA after end of all */ if (Term) { - buf = realloc(buf, pos + 2); + buf = io_realloc(buf, pos + 2); if (!buf) { LOGERR; return -1; @@ -281,7 +318,7 @@ cli_telnetSend(int sock, struct telnetAttrs *attr, int LOGERR; if (buf) - free(buf); + io_free(buf); return writeLen; } @@ -448,7 +485,7 @@ cli_telnet_SetCmd(struct telnetAttrs *attr, u_char cmd * @nCaps = number of capability options * @attr = input attribute * @nAttr = number of input attributes - * @ans = output answered attributes, must be free() after use + * @ans = output answered attributes, must be io_free() after use * @Ans = number of output answered attributes * return: -1 can`t answer; !=-1 ok */ @@ -484,7 +521,7 @@ cli_telnet_Answer(u_char *caps, int nCaps, struct teln // make attribute ... if (flg > -1) { (*Ans)++; - *ans = realloc(*ans, sizeof(struct telnetAttrs) * *Ans); + *ans = io_realloc(*ans, sizeof(struct telnetAttrs) * *Ans); if (!*ans) { LOGERR; return -1;