- client: fix uninitialized vars in CPU feature detection (from RustyBSD)

This commit is contained in:
David Anderson 2012-11-24 01:28:46 -08:00 committed by Oliver Bock
parent f31a63b0c8
commit 016b11e522
4 changed files with 54 additions and 40 deletions

View File

@ -7000,3 +7000,14 @@ David 22 Nov 2012
sched/ sched/
handle_request.cpp handle_request.cpp
David 23 Nov 2012
- client: fix uninitialized vars in CPU feature detection (from RustyBSD)
client/
hostinfo_unix.cpp
html/
inc/
submit.inc
user/
sandbox.php

View File

@ -628,9 +628,10 @@ static void parse_cpuinfo_linux(HOST_INFO& host) {
void use_cpuid(HOST_INFO& host) { void use_cpuid(HOST_INFO& host) {
u_int p[4]; u_int p[4];
int hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow, has3DNowExt = 0; int hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow, has3DNowExt;
char capabilities[256]; char capabilities[256];
hasMMX = hasSSE = hasSSE2 = hasSSE3 = has3DNow = has3DNowExt = 0;
do_cpuid(0x0, p); do_cpuid(0x0, p);
if (p[0] >= 0x1) { if (p[0] >= 0x1) {
@ -652,12 +653,12 @@ void use_cpuid(HOST_INFO& host) {
} }
capabilities[0] = '\0'; capabilities[0] = '\0';
if (hasSSE) strncat(capabilities, "sse ", 4); if (hasSSE) strcat(capabilities, "sse ");
if (hasSSE2) strncat(capabilities, "sse2 ", 5); if (hasSSE2) strcat(capabilities, "sse2 ");
if (hasSSE3) strncat(capabilities, "sse3 ", 5); if (hasSSE3) strcat(capabilities, "sse3 ");
if (has3DNow) strncat(capabilities, "3dnow ", 6); if (has3DNow) strcat(capabilities, "3dnow ");
if (has3DNowExt) strncat(capabilities, "3dnowext ", 9); if (has3DNowExt) strcat(capabilities, "3dnowext ");
if (hasMMX) strncat(capabilities, "mmx ", 4); if (hasMMX) strcat(capabilities, "mmx ");
strip_whitespace(capabilities); strip_whitespace(capabilities);
char buf[1024]; char buf[1024];
snprintf(buf, sizeof(buf), "%s [] [%s]", snprintf(buf, sizeof(buf), "%s [] [%s]",
@ -1338,7 +1339,7 @@ int HOST_INFO::get_host_info() {
m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_PHYS_PAGES); m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_PHYS_PAGES);
if (m_nbytes < 0) { if (m_nbytes < 0) {
msg_printf(NULL, MSG_INTERNAL_ERROR, msg_printf(NULL, MSG_INTERNAL_ERROR,
"RAM size not measured correctly: page size %d, #pages %d", "RAM size not measured correctly: page size %ld, #pages %ld",
sysconf(_SC_PAGESIZE), sysconf(_SC_PHYS_PAGES) sysconf(_SC_PAGESIZE), sysconf(_SC_PHYS_PAGES)
); );
} }

View File

@ -57,6 +57,8 @@ function req_to_xml($req, $op) {
$x .= " <mode>$file->mode</mode>\n"; $x .= " <mode>$file->mode</mode>\n";
switch ($file->mode) { switch ($file->mode) {
case "remote": case "remote":
$x .= " <source>$file->source</source>\n";
break;
case "local": case "local":
$x .= " <path>$file->path</path>\n"; $x .= " <path>$file->path</path>\n";
break; break;
@ -65,7 +67,7 @@ function req_to_xml($req, $op) {
case "semilocal": case "semilocal":
$x .= " <url>$file->url</url>\n"; $x .= " <url>$file->url</url>\n";
break; break;
<source>$file->source</source> }
$x .= " </input_file>\n"; $x .= " </input_file>\n";
} }
$x .= " </job> $x .= " </job>

View File

@ -52,7 +52,7 @@ function list_files($user, $err_msg) {
</form> </form>
<hr> <hr>
"; ";
if(strcmp($err_msg,"")!=0){ if (strcmp($err_msg,"")!=0){
echo "<p>$err_msg<hr>"; echo "<p>$err_msg<hr>";
} }
$files = array(); $files = array();
@ -67,7 +67,7 @@ function list_files($user, $err_msg) {
sort($files); sort($files);
start_table(); start_table();
table_header("Name<br><span class=note>(click to view)</span>", "Modified", "Size (bytes)", "MD5", "Delete","Download"); table_header("Name<br><span class=note>(click to view)</span>", "Modified", "Size (bytes)", "MD5", "Delete","Download");
foreach($files as $f) { foreach ($files as $f) {
$path = "$dir/$f"; $path = "$dir/$f";
list($error, $size, $md5) = sandbox_parse_link_file($path); list($error, $size, $md5) = sandbox_parse_link_file($path);
if ($error) { if ($error) {
@ -102,36 +102,36 @@ function list_files($user, $err_msg) {
function upload_file($user) { function upload_file($user) {
$tmp_name = $_FILES['new_file']['tmp_name']; $tmp_name = $_FILES['new_file']['tmp_name'];
if (is_uploaded_file($tmp_name)) { if (!is_uploaded_file($tmp_name)) {
$name = $_FILES['new_file']['name']; error_page("$tmp_name is not uploaded file");
if (strstr($name, "/")) { }
error_page("no / allowed"); $name = $_FILES['new_file']['name'];
} if (strstr($name, "/")) {
$md5 = md5_file($tmp_name); error_page("no / allowed");
$s = stat($tmp_name); }
$size = $s['size']; $md5 = md5_file($tmp_name);
list($exist,$elf) = sandbox_lf_exist($user,$md5); $s = stat($tmp_name);
if ($exist){ $size = $s['size'];
$notice = "<strong>Notice:</strong> Invalid Upload<br/>"; list($exist, $elf) = sandbox_lf_exist($user, $md5);
$notice .= "You are trying to upload file <strong>$name</strong><br/>"; if ($exist){
$notice .= "Another file <strong>$elf</strong> with the same content(md5: $md5) already exist!<br/>"; $notice = "<strong>Notice:</strong> Invalid Upload<br/>";
list_files($user,$notice); $notice .= "You are trying to upload file <strong>$name</strong><br/>";
return; $notice .= "Another file <strong>$elf</strong> with the same content(md5: $md5) already exist!<br/>";
} else{ } else{
// move file to download dir // move file to download dir
// //
$phys_path = sandbox_physical_path($user, $md5); $phys_path = sandbox_physical_path($user, $md5);
rename($tmp_name, $phys_path); rename($tmp_name, $phys_path);
// write link file // write link file
// //
$dir = sandbox_dir($user); $dir = sandbox_dir($user);
$link_path = "$dir/$name"; $link_path = "$dir/$name";
sandbox_write_link_file($link_path, $size, $md5); sandbox_write_link_file($link_path, $size, $md5);
$notice = "Successfully uploaded file <strong>$name</strong>!<br/>"; $notice = "Successfully uploaded file <strong>$name</strong>!<br/>";
list_files($user,$notice);
} }
} }
list_files($user, $notice);
} }
function delete_file($user) { function delete_file($user) {
@ -145,7 +145,7 @@ function delete_file($user) {
if (!is_file($p)) { if (!is_file($p)) {
error_page("no such physical file"); error_page("no such physical file");
} }
$bused = sandbox_file_in_use($user,$name); $bused = sandbox_file_in_use($user, $name);
if ($bused){ if ($bused){
$notice = "<strong>$name</strong> is being used by batch(es), you can not delete it now!<br/>"; $notice = "<strong>$name</strong> is being used by batch(es), you can not delete it now!<br/>";
} else{ } else{
@ -161,14 +161,14 @@ function download_file($user) {
$name = get_str('name'); $name = get_str('name');
$dir = sandbox_dir($user); $dir = sandbox_dir($user);
list($err, $size, $md5) = sandbox_parse_link_file("$dir/$name"); list($err, $size, $md5) = sandbox_parse_link_file("$dir/$name");
if($err) { if ($err) {
error_page("can't parse link file"); error_page("can't parse link file");
} }
$p = sandbox_physical_path($user, $md5); $p = sandbox_physical_path($user, $md5);
if (!is_file($p)) { if (!is_file($p)) {
error_page("$p does not exist!"); error_page("$p does not exist!");
} }
do_download($p,$name); do_download($p, $name);
} }
function view_file($user) { function view_file($user) {
$name = get_str('name'); $name = get_str('name');