aboutsummaryrefslogtreecommitdiff
path: root/src/buffer.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* fix(receive): a receive 0 should immediately return, not blockThijs Schreijer5 days1-10/+13
| | | | | | | | The fix is slightly more complex because reading from a closed socket should still return a closed-error. fixes: #427 fixes: https://github.com/ledgetech/lua-resty-http/pull/313
* fix(receive): guard numeric pattern against size_t overflow on castThijs Schreijer5 days1-1/+2
| | | | | | Same class of bug as the maxsize cast: a double larger than SIZE_MAX cast to size_t is undefined behavior. Bound-check the numeric receive pattern before the cast, and cover it with a test.
* fix(receive): guard maxsize against size_t overflow on castThijs Schreijer5 days1-1/+2
| | | | | Casting a double larger than SIZE_MAX to size_t is undefined behavior; bound-check maxsize before the cast.
* feat(receive): add maxsize argument to bound memory usageThijs Schreijer2026-07-301-20/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | client:receive("*l") and receive("*a") are unbounded: a peer that never sends a newline, or never closes, makes LuaSocket buffer until the process runs out of memory (e.g. src/http.lua reading response headers in a loop). Add an optional maxsize argument that caps the payload a single call may accumulate, including prefix. - Hoist all argument validation ahead of timeout_markstart() so bad calls (maxsize < 1, #prefix >= maxsize, numeric pattern > maxsize) raise before any I/O and leave the socket untouched. - recvline/recvall take a budget and return a new internal BUF_OVERSIZED code, surfaced to Lua as the "oversized" error alongside "timeout"/"closed", with the partial held in the 3rd return value. - recvraw is left untouched: argument checks make the cap unreachable for numeric patterns. - Preserve three invariants: a timeout partial is always shorter than maxsize (safe to retry as prefix), completion beats the cap for *a, and no bytes are lost or skipped on overflow. - tcp.c, unixstream.c and serial.c all share this code path unchanged. Adds test coverage (argument errors, *l/*a boundaries, timeout/close at the cap, the drain idiom, numeric patterns, unix-stream mirror) and documents the new argument, error, and recovery idioms in docs/tcp.html.
* Fixe an issue with aux buffer init overwriting optional parameters in ↵Paul Kulchenko2022-03-181-1/+4
| | | | | receive() (#334) Fixes use on Lua >= 5.4.3
* buffer: pragma visibilityE. Westbrook2019-03-101-12/+7
|
* buffer.c: use LUASOCKET_PRIVATEE. Westbrook2019-02-251-7/+9
|
* New agnostic IPv4 IPv6 functions.Diego Nehab2015-08-221-12/+12
| | | | | Also dealing with EPROTOTYPE Yosemite seems to be throwing at us for no reason.
* New compat.h module implements luaL_setfuncs.Diego Nehab2015-08-211-0/+1
| | | | Makes initialization code simpler everywhere.
* Fixed timeout bug introduced by commit e81a6ffDiego Nehab2013-09-091-8/+4
|
* Remove warnings and fix makefile for Win32.Diego Nehab2012-12-111-6/+6
|
* Making progress toward a releaseDiego Nehab2012-04-231-2/+0
| | | | | | | | | | Documented headers.lua Update copyright date everywhere Remove RCSID from files Move version back to 2.1 rather than 2.1.1 Fixed url package to support ipv6 hosts Changed "domain" to "family" in tcp and udp structures Implemented getfamily methods
* Conditional creation of p_timeout instance 'tm'Liam Devine2012-04-111-0/+4
|
* Compiles with Lua 5.1.4 and Lua 5.2.0-beta, although the makefile needs ↵Liam Devine2012-04-111-1/+1
| | | | sorting out to take maybe a version number and also the local paths need removing.
* Preliminary IPv6 support for v2.1Diego Nehab2012-04-111-1/+1
|
* Saving before big changes to support IPv6.Diego Nehab2011-05-251-4/+10
|
* Decent makefiles!Diego Nehab2009-05-271-1/+1
|
* Crashy bug fixed in recvraw.Diego Nehab2007-06-111-5/+10
| | | | Also fixed returns on closed socket.
* Before compiling on Windows.Diego Nehab2005-10-071-37/+37
|
* Almost ready to release.Diego Nehab2005-09-291-2/+2
|
* Added check-links-nb.lua that check links in a non-blocking way.Diego Nehab2005-06-201-1/+2
|
* Seems to be working on windows.Diego Nehab2005-03-111-1/+1
|
* Forward server working on Mac OS X...Diego Nehab2005-02-081-1/+1
|
* Simplified use for sock:send.Diego Nehab2005-01-271-2/+2
|
* Almost ready for beta3Diego Nehab2004-11-271-1/+3
|
* Beta2 is out! Total timeout works on Windows.Diego Nehab2004-07-261-4/+4
|
* Gonna try my luck on windows...Diego Nehab2004-07-261-3/+14
|
* Changed send function.Diego Nehab2004-07-181-11/+12
|
* Still need to fix windows. :o/Diego Nehab2004-07-151-9/+13
|
* Added getstats.Diego Nehab2004-07-011-0/+14
|
* Moving on to beta2.Diego Nehab2004-07-011-44/+24
|
* Changed the return of the send function...Diego Nehab2004-06-171-2/+10
|
* Manual is almost done. HTTP is missing.Diego Nehab2004-06-151-1/+8
| | | | | | | Implemented new distribution scheme. Select is now purely C. HTTP reimplemented seems faster dunno why. LTN12 functions that coroutines fail gracefully.
* Previous bug fix caused a new bug. :o/Diego Nehab2004-05-281-1/+1
|
* Changed receive function. Now uniform with all other functions. Returns nilDiego Nehab2004-03-211-50/+34
| | | | | | on error, return partial result in the end. http.lua rewritten.
* Worked on the manual.Diego Nehab2004-02-041-1/+2
| | | | | Implemented stuffing (needs test) Added cddb and qp examples.
* Trying to get connect-with-timeout to work. Darwin works...Diego Nehab2004-01-181-7/+5
|
* Killed a few bugs found by Tomas.Diego Nehab2003-11-271-2/+4
|
* Finished implementation of LuaSocket 2.0 alpha on Linux.Diego Nehab2003-06-261-15/+18
| | | | Some testing still needed.
* Select re-implemented in a nicer way.Diego Nehab2003-06-091-2/+2
| | | | | | Few changes in internal class and group registration. Lua modules are compiled and built into library. Dynamic library tested in Linux and Mac OS X.
* Porting to LUA 5.0 finalDiego Nehab2003-05-251-184/+91
|
* Closer to release...Diego Nehab2003-03-281-0/+2
|
* Completed port to Lua 5.0-beta.Diego Nehab2003-03-201-5/+5
|
* Faltam testes de ftp e smtp. O resto passa.Diego Nehab2002-12-031-2/+2
|
* Initial revisionDiego Nehab2002-03-271-0/+338