#740 Properly check error values in error_string()
Closed: fixed 2 years ago by atikhonov. Opened 13 years ago by sgallagh.

#define IS_HASH_ERROR(error)  (((error) >= HASH_ERROR_BASE) && ((error) < HASH_ERROR_LIMIT))

const char *error_string(int error)
{
    if (IS_HASH_ERROR(error))
        return hash_error_string(error);

    return strerror(error);
}

IS_HASH_ERROR is not sufficient to guarantee that we haven't still received a negative value here. error_string() should check {{{error < 0}}} and return "Unknown error"


Fields changed

coverity: 10034 => 10035

Fields changed

coverity: 10035 => 10035, 10036, 10037, 10038, 10039, 10040

Hash errors are negative so the check should be like this:

const char *error_string(int error) {

    if (IS_HASH_ERROR(error))
        return hash_error_string(error);

    if (error < 0) return "Unknown error"); 
    else return strerror(error);

}

Fields changed

rhbz: => 0

Fields changed

blockedby: =>
blocking: =>
feature_milestone: =>
milestone: Tools Backlog => Tools 2.0
patch: => 0

Metadata Update from @sgallagh:
- Issue assigned to sbose
- Issue set to the milestone: Tools 2.0

7 years ago

Metadata Update from @atikhonov:
- Custom field component adjusted to None (was: DHash)
- Custom field patch reset (from 0)
- Custom field selected adjusted to None
- Custom field testsupdated reset (from 0)
- Custom field type adjusted to None (was: defect)
- Custom field version adjusted to None (was: 1.4.1)
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata