Fix SI bug causing core dump sending to closed fd
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / sisendt.c
index ae07edb..81a3be6 100644 (file)
 *  Abstract: This module contains various send functions:
 *                              SIsendt -- send tcp with queuing if would block
 *                              SIsendt_nq - send tcp without queuing if blocking
-
+*
 *  Date:     27 March 1995
 *  Author:   E. Scott Daniels
 *  Mod:                22 Feb 2002 - To better process queued data 
+*                      14 Feb 2020 - To fix index bug if fd < 0.
 *
 *****************************************************************************
 */
@@ -57,6 +58,10 @@ extern int SIsendt( struct ginfo_blk *gptr, int fd, char *ubuf, int ulen ) {
        errno = EINVAL;
        gptr->sierr = SI_ERR_SESSID;
 
+       if( fd < 0 ) {
+               return SI_ERROR;                                        // bad form trying to use this fd
+       }
+
        if( fd < MAX_FDS ) {                                    // straight from map if possible
                tpptr = gptr->tp_map[fd];
        } else {