Author: jelmer Date: 2005-08-31 14:25:18 +0000 (Wed, 31 Aug 2005) New Revision: 9825
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9825 Log: Correctly handle length argument to substr() Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c Changeset: Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c =================================================================== --- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c 2005-08-31 13:36:35 UTC (rev 9824) +++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c 2005-08-31 14:25:18 UTC (rev 9825) @@ -155,6 +155,7 @@ orig = mprToString(argv[0]); start_offset = mprToInt(argv[1]); + length = strlen(orig); if (start_offset < 0) start_offset += strlen(orig); if (start_offset < 0 || start_offset > strlen(orig)) { ejsSetErrorMsg(eid, "substr arg 2 out of bounds"); @@ -162,14 +163,12 @@ } if (argc == 3) { - length = mprToInt(argv[1]); + length = mprToInt(argv[2]); if (length < 0) length += strlen(orig) - start_offset; if (length < 0 || length+start_offset > strlen(orig)) { ejsSetErrorMsg(eid, "substr arg 3 out of bounds"); return -1; } - } else { - length = strlen(orig); } target = talloc_strndup(mprMemCtx(), orig+start_offset, length);
