Skip to content

Commit

Permalink
clean: remove needless LWS_PRE
Browse files Browse the repository at this point in the history
Several examples trim their buffer with an extra LWS_PRE from the end...
actually end should point to end the end of buf without a second LWS_PRE
reservation.

#2629
  • Loading branch information
nick87720z authored and lws-team committed May 17, 2022
1 parent 310abdd commit bfd921d
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
Expand Up @@ -167,7 +167,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
char buf[LWS_PRE + 1024], *start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
int n, idx = (int)(intptr_t)lws_get_opaque_user_data(wsi);
struct pss *pss = (struct pss *)user;

Expand Down
Expand Up @@ -30,7 +30,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
{
struct pss *pss = (struct pss *)user;
char buf[LWS_PRE + 1024], *start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
int n;

switch (reason) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
struct pss *pss = (struct pss *)user;
char value[32], *pr = &pss->result[LWS_PRE];
size_t e = sizeof(pss->result) - LWS_PRE;
Expand Down
Expand Up @@ -42,7 +42,7 @@ callback_dynamic_http(struct lws *wsi, enum lws_callback_reasons reason,
{
struct pss *pss = (struct pss *)user;
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
time_t t;
int n;
#if defined(LWS_HAVE_CTIME_R)
Expand Down
Expand Up @@ -57,7 +57,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
struct pss * pss = (struct pss *)user;
uint8_t buf[LWS_PRE + LWS_RECOMMENDED_MIN_HEADER_SPACE],
*start = &buf[LWS_PRE], *p = start,
*end = p + sizeof(buf) - LWS_PRE;
*end = buf + sizeof(buf) - 1;
int m, n;

switch (reason) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/acme-client/protocol_lws_acme_client.c
Expand Up @@ -136,7 +136,7 @@ callback_chall_http01(struct lws *wsi, enum lws_callback_reasons reason,
struct lws_vhost *vhost = lws_get_vhost(wsi);
struct acme_connection *ac = lws_vhost_user(vhost);
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
int n;

switch (reason) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/deaddrop/protocol_lws_deaddrop.c
Expand Up @@ -383,7 +383,7 @@ callback_deaddrop(struct lws *wsi, enum lws_callback_reasons reason,
struct pss_deaddrop *pss = (struct pss_deaddrop *)user;
uint8_t buf[LWS_PRE + LWS_RECOMMENDED_MIN_HEADER_SPACE],
*start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
char fname[256], *wp;
const char *cp;
int n, m, was;
Expand Down
2 changes: 1 addition & 1 deletion plugins/protocol_fulltext_demo.c
Expand Up @@ -65,7 +65,7 @@ callback_fts(struct lws *wsi, enum lws_callback_reasons reason, void *user,
lws_get_protocol(wsi));
struct pss_fts_demo *pss = (struct pss_fts_demo *)user;
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
*end = &buf[sizeof(buf) - LWS_PRE - 1];
*end = &buf[sizeof(buf) - 1];
struct lws_fts_search_params params;
const char *ccp = (const char *)in;
struct lws_fts_result *result;
Expand Down

0 comments on commit bfd921d

Please sign in to comment.