浏览代码

Do not assume NULL termination on the ut_id field. Thanks
to mac12@po.cwru.edu for spotting this one.

Eric Andersen 23 年之前
父节点
当前提交
30b32340bd
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      libc/misc/utmp/utent.c

+ 1 - 1
libc/misc/utmp/utent.c

@@ -138,7 +138,7 @@ struct utmp *getutid (const struct utmp *utmp_entry)
 		 utmp_entry->ut_type == DEAD_PROCESS ||
 		 utmp_entry->ut_type == LOGIN_PROCESS ||
 		 utmp_entry->ut_type == USER_PROCESS) &&
-		!strcmp(lutmp->ut_id, utmp_entry->ut_id)) 
+		!strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id))) 
 	{
 	    return lutmp;
 	}