@@ -458,7 +458,7 @@ handle_accept(const AcceptMessage *msg, const uint8_t *buf, size_t len,
458458 }
459459
460460 /* Check that message is valid. */
461- if (msg -> submit_time == NULL || msg -> n_info_msgs == 0 ) {
461+ if (msg == NULL || msg -> submit_time == NULL || msg -> n_info_msgs == 0 ) {
462462 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid AcceptMessage" ));
463463 closure -> errstr = _ ("invalid AcceptMessage" );
464464 debug_return_bool (false);
@@ -495,7 +495,8 @@ handle_reject(const RejectMessage *msg, const uint8_t *buf, size_t len,
495495 }
496496
497497 /* Check that message is valid. */
498- if (msg -> submit_time == NULL || msg -> n_info_msgs == 0 ) {
498+ if (msg == NULL || msg -> submit_time == NULL || msg -> reason [0 ] == '\0' ||
499+ msg -> n_info_msgs == 0 ) {
499500 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid RejectMessage" ));
500501 closure -> errstr = _ ("invalid RejectMessage" );
501502 debug_return_bool (false);
@@ -527,7 +528,7 @@ handle_exit(const ExitMessage *msg, const uint8_t *buf, size_t len,
527528 }
528529
529530 /* Check that message is valid. */
530- if (msg -> run_time == NULL ) {
531+ if (msg == NULL || msg -> run_time == NULL ) {
531532 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid ExitMessage" ));
532533 closure -> errstr = _ ("invalid ExitMessage" );
533534 debug_return_bool (false);
@@ -581,7 +582,7 @@ handle_restart(const RestartMessage *msg, const uint8_t *buf, size_t len,
581582 }
582583
583584 /* Check that message is valid. */
584- if (msg -> log_id == NULL || msg -> resume_point == NULL ) {
585+ if (msg == NULL || msg -> log_id [ 0 ] == '\0' || msg -> resume_point == NULL ) {
585586 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid RestartMessage" ));
586587 closure -> errstr = _ ("invalid RestartMessage" );
587588 debug_return_bool (false);
@@ -616,7 +617,7 @@ handle_alert(const AlertMessage *msg, const uint8_t *buf, size_t len,
616617 debug_decl (handle_alert , SUDO_DEBUG_UTIL );
617618
618619 /* Check that message is valid. */
619- if (msg -> alert_time == NULL || msg -> reason == NULL ) {
620+ if (msg == NULL || msg -> alert_time == NULL || msg -> reason [ 0 ] == '\0' ) {
620621 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid AlertMessage" ));
621622 closure -> errstr = _ ("invalid AlertMessage" );
622623 debug_return_bool (false);
@@ -665,7 +666,7 @@ handle_iobuf(int iofd, const IoBuffer *iobuf, const uint8_t *buf, size_t len,
665666 }
666667
667668 /* Check that message is valid. */
668- if (iobuf -> delay == NULL ) {
669+ if (iobuf == NULL || iobuf -> delay == NULL || iobuf -> data . len == 0 ) {
669670 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid IoBuffer" ));
670671 closure -> errstr = _ ("invalid IoBuffer" );
671672 debug_return_bool (false);
@@ -701,7 +702,7 @@ handle_winsize(const ChangeWindowSize *msg, const uint8_t *buf, size_t len,
701702 }
702703
703704 /* Check that message is valid. */
704- if (msg -> delay == NULL ) {
705+ if (msg == NULL || msg -> delay == NULL ) {
705706 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid ChangeWindowSize" ));
706707 closure -> errstr = _ ("invalid ChangeWindowSize" );
707708 debug_return_bool (false);
@@ -737,7 +738,7 @@ handle_suspend(const CommandSuspend *msg, const uint8_t *buf, size_t len,
737738 }
738739
739740 /* Check that message is valid. */
740- if (msg -> delay == NULL || msg -> signal == NULL ) {
741+ if (msg == NULL || msg -> delay == NULL || msg -> signal [ 0 ] == '\0' ) {
741742 sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid CommandSuspend" ));
742743 closure -> errstr = _ ("invalid CommandSuspend" );
743744 debug_return_bool (false);
@@ -767,10 +768,16 @@ handle_client_hello(const ClientHello *msg, const uint8_t *buf, size_t len,
767768 debug_return_bool (false);
768769 }
769770
771+ /* Check that message is valid. */
772+ if (msg == NULL || msg -> client_id [0 ] == '\0' ) {
773+ sudo_warnx (U_ ("%s: %s" ), source , U_ ("invalid ClientHello" ));
774+ closure -> errstr = _ ("invalid ClientHello" );
775+ debug_return_bool (false);
776+ }
770777 sudo_debug_printf (SUDO_DEBUG_INFO , "%s: received ClientHello" ,
771778 __func__ );
772779 sudo_debug_printf (SUDO_DEBUG_INFO , "%s: client ID %s" ,
773- __func__ , msg -> client_id ? msg -> client_id : "unknown" );
780+ __func__ , msg -> client_id );
774781
775782 debug_return_bool (true);
776783}
0 commit comments