Changeset 28c4fd3 in code


Ignore:
Timestamp:
Mar 14, 2014, 8:40:28 PM (11 years ago)
Author:
Mike Belopuhov <mike@…>
Branches:
master
Children:
ad8b08d
Parents:
de86230
git-author:
Mike Belopuhov <mike@…> (03/14/14 20:30:45)
git-committer:
Mike Belopuhov <mike@…> (03/14/14 20:40:28)
Message:

Florian has pointed out that logger code suffers from the same problem
as the main code. So first of all don't forget to subtract the amount
of what's already read from the total length; secondly correct the
condition to check partial read.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • logger.c

    rde86230 r28c4fd3  
    183183                                return;
    184184                }
     185                if (e->length >= ICB_MSGSIZE) {
     186                        syslog(LOG_ERR, "%s: message too big: %lu", __func__,
     187                            e->length);
     188                        exit(EX_DATAERR);
     189                }
    185190                /* fetch the message */
    186191                res = bufferevent_read(bev, &buf[nread],
    187                     MIN(e->length, ICB_MSGSIZE));
     192                    e->length - (nread - sizeof *e));
    188193                nread += res;
    189194#ifdef DEBUG
     
    195200                }
    196201#endif
    197                 if (nread < e->length)
     202                if (nread - sizeof *e < e->length)
    198203                        return;
    199204                /* terminate the buffer */
     
    304309        if (evtimer_add(&ev_tick, &tv) < 0) {
    305310                syslog(LOG_ERR, "%s: evtimer_add: %m", __func__);
    306                 exit (EX_UNAVAILABLE);
    307         }
    308 }
     311                exit(EX_UNAVAILABLE);
     312        }
     313}
Note: See TracChangeset for help on using the changeset viewer.