Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/953#discussion_r100864662
  
    --- Diff: core/sql/cli/memorymonitor.cpp ---
    @@ -223,12 +229,12 @@ void MemoryMonitor::update(float &scale) {
        char * currPtr;
             bytesRead = fread(buffer, 1, 2048, fd_meminfo_);
             // Make sure there wasn't an error (next fseek will clear eof)
    -        if (!feof(fd_meminfo_))// Make sure there wasn't an error
    -        {
    -           scale = 6;
    -           pressure_ = 0;
    -           return;
    -        }
    +        if (ferror(fd_meminfo_))
    +           assert(false); 
    +        if (feof(fd_meminfo_))
    +           clearerr(fd_meminfo_); 
    +        else
    +           buffer[bytesRead] = '\0';
    --- End diff --
    
    If we get an EOF, which should be the normal case, then shouldn't we also 
set buffer[bytesRead] to \0? In either case, to do that, we would need to 
allocate one extra byte to avoid a buffer overrun.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to