Steven Dake wrote:
> On 06/01/2011 09:14 AM, Jan Friesse wrote:
>> Signed-off-by: Jan Friesse <[email protected]>
>> ---
>>  lib/coroipcc.c |    8 ++++++++
>>  1 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/lib/coroipcc.c b/lib/coroipcc.c
>> index 1adce0e..862047d 100644
>> --- a/lib/coroipcc.c
>> +++ b/lib/coroipcc.c
>> @@ -311,6 +311,10 @@ circular_memory_map (char *path, const char *file, void 
>> **buf, size_t bytes)
>>      }
>>  
>>      page_size = sysconf(_SC_PAGESIZE);
>> +    if (page_size < 0) {
>> +            goto error_close_unlink;
>> +    }
>> +
>>      buffer = malloc (page_size);
>>      if (buffer == NULL) {
>>              goto error_close_unlink;
>> @@ -417,6 +421,10 @@ memory_map (char *path, const char *file, void **buf, 
>> size_t bytes)
>>              goto error_close_unlink;
>>      }
>>      page_size = sysconf(_SC_PAGESIZE);
>> +    if (page_size < 0) {
>> +            goto error_close_unlink;
>> +    }
>> +
>>      buffer = malloc (page_size);
>>      if (buffer == NULL) {
>>              goto error_close_unlink;
> 
> Prefer a direct comparison for the error condition ie:
> if (page_size == -1) {
> }
> RETURN VALUE
>        If name is invalid, -1 is returned, and errno is set to EINVAL.
> Other‐
>        wise, the value returned is the value of the system resource and
>  errno
>        is  not  changed.  In the case of options, a positive value is
> returned
>        if a queried option is available, and -1 if it is not.  In the
> case  of
>        limits, -1 means that there is no definite limit.
> 
> 

Main problem is not -1 but fact, that malloc takes unsigned and sysconf
return signed. According to man page:

 PAGESIZE - _SC_PAGESIZE
              Size of a page in bytes. Must not be less than 1.  (Some
systems use PAGE_SIZE instead.)

So I can imagine test for < 1, but patch seem to me makes much more
sense with < 0.
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to