[LITMUS^RT] proposing liblitmus API additions and changes

Björn Brandenburg bbb at mpi-sws.org
Tue Jul 2 00:15:29 CEST 2013


On Jun 28, 2013, at 5:52 AM, Glenn Elliott <gelliott at cs.unc.edu> wrote:

> Yes, that certainly looks like a bug.  Thanks for the help!
> 
> On Jun 27, 2013, at 6:35 PM, Hiroyuki Chishiro <chishiro at cs.unc.edu> wrote:
> 
>>  
>> Hi Glenn,
>>  
>> I hit a bug in release_master() in "liblitmus/src/migration.c".
>>  
>>   11  int release_master()
>>   12  {
>>   13  static const char NO_CPU[] = "NO_CPU";
>>   14  char buf[5] = {0}; /* up to 9999 CPUs */
>>   15  int master = -1;
>>   16  
>>   17  int ret = read_file("/proc/litmus/release_master", &buf, sizeof(buf)-1);
>>   18  
>>   19  if ((ret > 0) && (strncmp(buf, NO_CPU, sizeof(NO_CPU)-1) != 0))
>>   20  master = atoi(buf);
>>   21  
>>   22  return master;
>>   23  }
>>  
>>  
>> If /proc/litmus/release_master is "NO_CPU", then buf = "NO_C" in line 17 because sizeof(buf) - 1 = 4.
>> So "strncmp(buf, NO_CPU, sizeof(NO_CPU)-1) != 0" in line 19 is always true because sizeof(NO_CPU) - 1 = 6. 
>>  
>> I think that the size of buf should be 7.
>>  
>>   14  char buf[7] = {0}; /* up to 999999 CPUs */
>>  
>> - Hiro 
>>  


Any patch to merge?

Thanks,
Björn




More information about the litmus-dev mailing list