Skip to content

Commit 18d9c3e

Browse files
bagdercmeister2
authored andcommitted
websockets: build a dedicated websocket fuzzer
1 parent 543b992 commit 18d9c3e

File tree

4 files changed

+37
-35
lines changed

4 files changed

+37
-35
lines changed

Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# | (__| |_| | _ <| |___
66
# \___|\___/|_| \_\_____|
77
#
8-
# Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
8+
# Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al.
99
#
1010
# This software is licensed as described in the file COPYING, which
1111
# you should have received as part of this distribution. The terms
@@ -52,6 +52,7 @@ FUZZPROGS = curl_fuzzer \
5252
curl_fuzzer_sftp \
5353
curl_fuzzer_smb \
5454
curl_fuzzer_smtp \
55+
curl_fuzzer_ws \
5556
curl_fuzzer_tftp
5657
FUZZLIBS = libstandaloneengine.a
5758

@@ -119,6 +120,9 @@ curl_fuzzer_smtp_LDADD = $(COMMON_LDADD)
119120
curl_fuzzer_tftp_SOURCES = $(COMMON_SOURCES)
120121
curl_fuzzer_tftp_CXXFLAGS = $(COMMON_FLAGS) -DFUZZ_PROTOCOLS_TFTP
121122
curl_fuzzer_tftp_LDADD = $(COMMON_LDADD)
123+
curl_fuzzer_ws_SOURCES = $(COMMON_SOURCES)
124+
curl_fuzzer_ws_CXXFLAGS = $(COMMON_FLAGS) -DFUZZ_PROTOCOLS_WS
125+
curl_fuzzer_ws_LDADD = $(COMMON_LDADD)
122126

123127
# Unit test fuzzers
124128
curl_fuzzer_fnmatch_SOURCES = fuzz_fnmatch.cc

curl_fuzzer.cc

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* | (__| |_| | _ <| |___
66
* \___|\___/|_| \_\_____|
77
*
8-
* Copyright (C) 2017 - 2021, Max Dymond, <[email protected]>, et al.
8+
* Copyright (C) 2017 - 2022, Max Dymond, <[email protected]>, et al.
99
*
1010
* This software is licensed as described in the file COPYING, which
1111
* you should have received as part of this distribution. The terms
@@ -462,81 +462,78 @@ int fuzz_select(int nfds,
462462
}
463463

464464
/**
465-
* Set allowed protocols based on the compile options
465+
* Set allowed protocols based on the compile options.
466+
*
467+
* Note that it can only use ONE of the FUZZ_PROTOCOLS_* defines.a
466468
*/
467469
int fuzz_set_allowed_protocols(FUZZ_DATA *fuzz)
468470
{
469471
int rc = 0;
470-
unsigned long allowed_protocols = 0;
472+
const char *allowed_protocols = "";
471473

472474
#ifdef FUZZ_PROTOCOLS_ALL
473475
/* Do not allow telnet currently as it accepts input from stdin. */
474-
allowed_protocols |= CURLPROTO_ALL & ~CURLPROTO_TELNET;
476+
allowed_protocols =
477+
"dict,file,ftp,ftps,gopher,gophers,http,https,imap,imaps,"
478+
"ldap,ldaps,mqtt,pop3,pop3s,rtmp,rtmpe,rtmps,rtmpt,rtmpte,rtmpts,"
479+
"rtsp,scp,sftp,smb,smbs,smtp,smtps,tftp";
475480
#endif
476481
#ifdef FUZZ_PROTOCOLS_DICT
477-
allowed_protocols |= CURLPROTO_DICT;
482+
allowed_protocols = "dict";
478483
#endif
479484
#ifdef FUZZ_PROTOCOLS_FILE
480-
allowed_protocols |= CURLPROTO_FILE;
485+
allowed_protocols = "file";
481486
#endif
482487
#ifdef FUZZ_PROTOCOLS_FTP
483-
allowed_protocols |= CURLPROTO_FTP;
484-
allowed_protocols |= CURLPROTO_FTPS;
488+
allowed_protocols = "ftp,ftps";
485489
#endif
486490
#ifdef FUZZ_PROTOCOLS_GOPHER
487-
allowed_protocols |= CURLPROTO_GOPHER;
491+
allowed_protocols = "gopher,gophers";
488492
#endif
489493
#ifdef FUZZ_PROTOCOLS_HTTP
490-
allowed_protocols |= CURLPROTO_HTTP;
494+
allowed_protocols = "http";
491495
#endif
492496
#ifdef FUZZ_PROTOCOLS_HTTPS
493-
allowed_protocols |= CURLPROTO_HTTPS;
497+
allowed_protocols = "https";
494498
#endif
495499
#ifdef FUZZ_PROTOCOLS_IMAP
496-
allowed_protocols |= CURLPROTO_IMAP;
497-
allowed_protocols |= CURLPROTO_IMAPS;
500+
allowed_protocols = "imap,imaps";
498501
#endif
499502
#ifdef FUZZ_PROTOCOLS_LDAP
500-
allowed_protocols |= CURLPROTO_LDAP;
501-
allowed_protocols |= CURLPROTO_LDAPS;
503+
allowed_protocols = "ldap,ldaps";
502504
#endif
503505
#ifdef FUZZ_PROTOCOLS_MQTT
504-
allowed_protocols |= CURLPROTO_MQTT;
506+
allowed_protocols = "mqtt";
505507
#endif
506508
#ifdef FUZZ_PROTOCOLS_POP3
507-
allowed_protocols |= CURLPROTO_POP3;
508-
allowed_protocols |= CURLPROTO_POP3S;
509+
allowed_protocols = "pop3,pop3s";
509510
#endif
510511
#ifdef FUZZ_PROTOCOLS_RTMP
511-
allowed_protocols |= CURLPROTO_RTMP;
512-
allowed_protocols |= CURLPROTO_RTMPE;
513-
allowed_protocols |= CURLPROTO_RTMPS;
514-
allowed_protocols |= CURLPROTO_RTMPT;
515-
allowed_protocols |= CURLPROTO_RTMPTE;
516-
allowed_protocols |= CURLPROTO_RTMPTS;
512+
allowed_protocols = "rtmp,rtmpe,rtmps,rtmpt,rtmpte,rtmpts";
517513
#endif
518514
#ifdef FUZZ_PROTOCOLS_RTSP
519-
allowed_protocols |= CURLPROTO_RTSP;
515+
allowed_protocols = "rtsp";
520516
#endif
521517
#ifdef FUZZ_PROTOCOLS_SCP
522-
allowed_protocols |= CURLPROTO_SCP;
518+
allowed_protocols = "scp";
523519
#endif
524520
#ifdef FUZZ_PROTOCOLS_SFTP
525-
allowed_protocols |= CURLPROTO_SFTP;
521+
allowed_protocols = "sftp";
526522
#endif
527523
#ifdef FUZZ_PROTOCOLS_SMB
528-
allowed_protocols |= CURLPROTO_SMB;
529-
allowed_protocols |= CURLPROTO_SMBS;
524+
allowed_protocols = "smb,smbs";
530525
#endif
531526
#ifdef FUZZ_PROTOCOLS_SMTP
532-
allowed_protocols |= CURLPROTO_SMTP;
533-
allowed_protocols |= CURLPROTO_SMTPS;
527+
allowed_protocols = "smtp,smtps";
534528
#endif
535529
#ifdef FUZZ_PROTOCOLS_TFTP
536-
allowed_protocols |= CURLPROTO_TFTP;
530+
allowed_protocols = "tftp";
531+
#endif
532+
#ifdef FUZZ_PROTOCOLS_WS
533+
allowed_protocols = "ws,wss";
537534
#endif
538535

539-
FTRY(curl_easy_setopt(fuzz->easy, CURLOPT_PROTOCOLS, allowed_protocols));
536+
FTRY(curl_easy_setopt(fuzz->easy, CURLOPT_PROTOCOLS_STR, allowed_protocols));
540537

541538
EXIT_LABEL:
542539

scripts/fuzz_targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
export FUZZ_TARGETS="curl_fuzzer_dict curl_fuzzer_file curl_fuzzer_ftp curl_fuzzer_gopher curl_fuzzer_http curl_fuzzer_https curl_fuzzer_imap curl_fuzzer_ldap curl_fuzzer_mqtt curl_fuzzer_pop3 curl_fuzzer_rtmp curl_fuzzer_rtsp curl_fuzzer_scp curl_fuzzer_sftp curl_fuzzer_smb curl_fuzzer_smtp curl_fuzzer_tftp curl_fuzzer"
3+
export FUZZ_TARGETS="curl_fuzzer_dict curl_fuzzer_file curl_fuzzer_ftp curl_fuzzer_gopher curl_fuzzer_http curl_fuzzer_https curl_fuzzer_imap curl_fuzzer_ldap curl_fuzzer_mqtt curl_fuzzer_pop3 curl_fuzzer_rtmp curl_fuzzer_rtsp curl_fuzzer_scp curl_fuzzer_sftp curl_fuzzer_smb curl_fuzzer_smtp curl_fuzzer_tftp curl_fuzzer_ws curl_fuzzer"

scripts/install_curl.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pushd ${SRCDIR}
5353
--enable-maintainer-mode \
5454
--disable-symbol-hiding \
5555
--enable-ipv6 \
56+
--enable-websockets \
5657
--with-random=/dev/null \
5758
${SSLOPTION} \
5859
${NGHTTPOPTION} \

0 commit comments

Comments
 (0)