소스 검색

Bug 630097 - (cov#15509) NULL dereference in idsktune

If strdup() fails, the cmd variable will be NULL.  We dereference
it without checking it strdup() was successful.  We should check
if cmd is NULL before dereferencing it.
Nathan Kinder 15 년 전
부모
커밋
55f94d2a6a
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      ldap/systools/idsktune.c

+ 5 - 0
ldap/systools/idsktune.c

@@ -1108,6 +1108,11 @@ linux_check_release(void)
   char osl[128];
   char *cmd = strdup("/bin/uname -r");
 
+  if (cmd == NULL) {
+    printf("ERROR: Unable to allocate memory\n");
+    goto done;
+  }
+
   if (flag_html) printf("<P>\n");
   if (flag_debug) printf("DEBUG  : %s\n",cmd);
   fp = popen(cmd,"r");