Skip to content

Commit e7b0087

Browse files
committed
fixes
1 parent 0963bd9 commit e7b0087

7 files changed

Lines changed: 40 additions & 21 deletions

File tree

include/libwebsockets/lws-system.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ typedef enum {
182182
LWS_CPD_NO_INTERNET, /* we couldn't touch anything */
183183
} lws_cpd_result_t;
184184

185+
#if defined(LWS_WITH_NETWORK)
185186
typedef enum {
186187
LWS_EXTIP_SRC_DHT,
187188
LWS_EXTIP_SRC_EXTIP
188189
} lws_extip_src_t;
190+
#endif
189191

190192
typedef void (*lws_attach_cb_t)(struct lws_context *context, int tsi, void *opaque);
191193
struct lws_attach_item;
@@ -269,6 +271,7 @@ typedef struct lws_system_ops {
269271
#endif
270272
} lws_system_ops_t;
271273

274+
#if defined(LWS_WITH_NETWORK)
272275
/**
273276
* lws_extip_report() - update external IP tracking state from callback
274277
*
@@ -298,6 +301,7 @@ lws_extip_report(struct lws_context *cx, lws_extip_src_t src, const lws_sockaddr
298301
*/
299302
LWS_VISIBLE LWS_EXTERN int
300303
lws_extip_get_best(struct lws_context *cx, int af, lws_sockaddr46 *sa46);
304+
#endif
301305

302306
#if defined(LWS_WITH_SYS_STATE)
303307

lib/plat/unix/unix-spawn.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)
466466
if (slave >= 0) {
467467
struct termios t;
468468
tcgetattr(slave, &t);
469-
cfmakeraw(&t);
469+
t.c_iflag &= (tcflag_t)~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
470+
t.c_oflag &= (tcflag_t)~OPOST;
471+
t.c_lflag &= (tcflag_t)~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
472+
t.c_cflag &= (tcflag_t)~(CSIZE | PARENB);
473+
t.c_cflag |= CS8;
470474
tcsetattr(slave, TCSANOW, &t);
471475
lsp->pipe_fds[n][0] = master;
472476
lsp->pipe_fds[n][1] = slave;
@@ -745,20 +749,29 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)
745749
* Bind the child's stdin / out / err to its side of our pipes
746750
*/
747751

748-
for (m = 0; m < 3; m++) {
749-
if (dup2(lsp->pipe_fds[m][m != 0], m) < 0) {
750-
lwsl_err("%s: stdin dup2 failed\n", __func__);
751-
goto bail3;
752+
{
753+
int cfd[3];
754+
755+
for (m = 0; m < 3; m++)
756+
cfd[m] = lsp->pipe_fds[m][m != 0];
757+
758+
for (m = 0; m < 3; m++) {
759+
if (cfd[m] < 0)
760+
continue;
761+
if (dup2(cfd[m], m) < 0) {
762+
lwsl_err("%s: dup2 failed for fd index %d (oldfd %d, newfd %d): errno %d (%s)\n",
763+
__func__, m, cfd[m], m, errno, strerror(errno));
764+
goto bail3;
765+
}
752766
}
753-
/*
754-
* CLOEXEC on the lws-side of the pipe fds should have already
755-
* dealt with closing those for the child perspective.
756-
*
757-
* Now it has done the dup, the child should close its original
758-
* copies of its side of the pipes.
759-
*/
760767

761-
close(lsp->pipe_fds[m][m != 0]);
768+
for (m = 0; m < 3; m++) {
769+
if (cfd[m] >= 0 && cfd[m] != 0 && cfd[m] != 1 && cfd[m] != 2) {
770+
close(cfd[m]);
771+
if (i->pty_mode && m == LWS_STDOUT)
772+
cfd[LWS_STDERR] = -1; /* Prevent double close */
773+
}
774+
}
762775
}
763776

764777
#if defined(__sun) || !defined(LWS_HAVE_VFORK) || !defined(LWS_HAVE_EXECVPE)

lib/roles/http/server/lejp-conf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,6 @@ lwsws_get_config_vhosts(struct lws_context *context,
13291329
if (!vh)
13301330
return 1;
13311331

1332-
extern int lws_context_init_ssl_library(struct lws_context *cx, const struct lws_context_creation_info *info);
13331332
lws_context_init_ssl_library(context, &i);
13341333
lws_init_vhost_client_ssl(&i, vh);
13351334

lib/system/system.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ lws_system_do_attach(struct lws_context_per_thread *pt)
262262
return 0;
263263
}
264264

265-
#endif
266-
267265
void
268266
lws_extip_report(struct lws_context *cx, lws_extip_src_t src,
269267
const lws_sockaddr46 *sa46, int af, int status,
@@ -287,7 +285,9 @@ lws_extip_report(struct lws_context *cx, lws_extip_src_t src,
287285
}
288286

289287
if (memcmp(&old, target, sizeof(*target))) {
288+
#if defined(LWS_WITH_IPV6)
290289
int c = 0;
290+
#endif
291291
char payload[128], buf4[64];
292292
char *p = payload, *end = payload + sizeof(payload);
293293

@@ -296,7 +296,9 @@ lws_extip_report(struct lws_context *cx, lws_extip_src_t src,
296296
if (cx->ext_ipv4.sa4.sin_family == AF_INET) {
297297
lws_sa46_write_numeric_address(&cx->ext_ipv4, buf4, sizeof(buf4));
298298
p += lws_snprintf(p, lws_ptr_diff_size_t(end, p), "\"%s\"", buf4);
299+
#if defined(LWS_WITH_IPV6)
299300
c++;
301+
#endif
300302
}
301303

302304
#if defined(LWS_WITH_IPV6)
@@ -340,3 +342,5 @@ lws_extip_get_best(struct lws_context *cx, int af, lws_sockaddr46 *sa46)
340342
memset(sa46, 0, sizeof(*sa46));
341343
return 1;
342344
}
345+
346+
#endif

minimal-examples-lowlevel/api-tests/api-test-x509/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main(int argc, const char **argv)
4343
return 1;
4444
}
4545

46-
if (lws_x509_parse_from_pem(x509, test_cert, strlen(test_cert))) {
46+
if (lws_x509_parse_from_pem(x509, test_cert, strlen(test_cert) + 1)) {
4747
lwsl_err("lws_x509_parse_from_pem failed\n");
4848
ret = 1;
4949
goto bail;

minimal-examples-lowlevel/dbus-server/minimal-dbus-ws-proxy/protocol_lws_minimal_dbus_ws_proxy.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,13 @@ static DBusHandlerResult
217217
dmh_connect(DBusConnection *c, DBusMessage *m, DBusMessage **reply, void *d)
218218
{
219219
struct lws_dbus_ctx_wsproxy *wspctx = (struct lws_dbus_ctx_wsproxy *)d;
220-
const char *prot = "", *ads = "", *path = "", *baduri = "Bad Uri",
220+
const char *prot = "", *baduri = "Bad Uri",
221221
*connecting = "Connecting", *failed = "Failed", **pp;
222222
struct lws_client_connect_info i;
223223
char host[128];
224224
const char *uri, *subprotocol;
225225
lws_parse_uri_t *puri = NULL;
226226
DBusError err;
227-
int port = 0;
228227

229228
dbus_error_init(&err);
230229

plugins/protocol_lws_dht_dnssec_monitor/protocol_lws_dht_dnssec_monitor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ whois_cb(void *opaque, const struct lws_whois_results *res)
233233
now, now + 300);
234234

235235
if (lws_jwt_sign_compact(wqi->vhd->context, &wqi->vhd->auth_jwk, "HS256",
236-
jwt, &jwt_len, temp, sizeof(temp), jwt_payload)) {
236+
jwt, &jwt_len, temp, sizeof(temp), "%s", jwt_payload)) {
237237
lwsl_err("[INSTRUMENT] %s: failed to generate jwt for whois\n", __func__);
238238
}
239239
}
@@ -359,7 +359,7 @@ calc_local_ds(struct vhd *vhd, const char *domain, char *out, size_t out_len)
359359
memcpy(p, rdata, rdata_len);
360360
size_t pay_len = (size_t)lws_ptr_diff(p + rdata_len, payload);
361361

362-
int htype = LWS_GENHASH_TYPE_SHA256;
362+
enum lws_genhash_types htype = LWS_GENHASH_TYPE_SHA256;
363363
int dtype = 2;
364364
int dlen = 32;
365365
if (alg == 14) {

0 commit comments

Comments
 (0)