Fix potential for crash if tmxr_set_get_modem_bits is called without the multiplexer device being attached

This commit is contained in:
Mark Pizzolato 2013-01-24 12:09:40 -08:00
parent f7b2f44c9c
commit ab25ad54e8
2 changed files with 4 additions and 3 deletions

View file

@ -117,6 +117,7 @@
#include <winsock2.h> #include <winsock2.h>
#undef PACKED /* avoid macro name collision */ #undef PACKED /* avoid macro name collision */
#undef ERROR /* avoid macro name collision */ #undef ERROR /* avoid macro name collision */
#undef MEM_MAPPED /* avoid macro name collision */
#endif #endif
#ifndef TRUE #ifndef TRUE

View file

@ -1062,12 +1062,12 @@ if ((bits_to_set & ~(TMXR_MDM_OUTGOING)) || /* Assure only settable bits
(bits_to_set & bits_to_clear)) /* and can't set and clear the same bits */ (bits_to_set & bits_to_clear)) /* and can't set and clear the same bits */
return SCPE_ARG; return SCPE_ARG;
if (incoming_bits) { if (incoming_bits) {
if (lp->sock) if ((lp->sock) || (lp->serport))
*incoming_bits = TMXR_MDM_DCD | TMXR_MDM_CTS | TMXR_MDM_DSR; *incoming_bits = TMXR_MDM_DCD | TMXR_MDM_CTS | TMXR_MDM_DSR;
else else
*incoming_bits = lp->mp->master ? (TMXR_MDM_CTS | TMXR_MDM_DSR) : 0; *incoming_bits = (lp->mp && lp->mp->master) ? (TMXR_MDM_CTS | TMXR_MDM_DSR) : 0;
} }
if (lp->mp->modem_control) { /* This API ONLY works on modem_control enabled multiplexers */ if (lp->mp && lp->mp->modem_control) { /* This API ONLY works on modem_control enabled multiplexers */
if (lp->serport) if (lp->serport)
return sim_control_serial (lp->serport, bits_to_set, bits_to_clear, incoming_bits); return sim_control_serial (lp->serport, bits_to_set, bits_to_clear, incoming_bits);
if (lp->sock) { if (lp->sock) {