< prev index next >

src/share/vm/utilities/vmError.cpp

Print this page
rev 8113 : 8076475: Misuses of strncpy/strncat
Summary: Various small fixes around strncpy and strncat
Reviewed-by: dsamersoff


 446      // Is it an OS exception/signal?
 447      if (os::exception_name(_id, buf, sizeof(buf))) {
 448        st->print("%s", buf);
 449        st->print(" (0x%x)", _id);                // signal number
 450        st->print(" at pc=" PTR_FORMAT, _pc);
 451      } else {
 452        if (should_report_bug(_id)) {
 453          st->print("Internal Error");
 454        } else {
 455          st->print("Out of Memory Error");
 456        }
 457        if (_filename != NULL && _lineno > 0) {
 458 #ifdef PRODUCT
 459          // In product mode chop off pathname?
 460          char separator = os::file_separator()[0];
 461          const char *p = strrchr(_filename, separator);
 462          const char *file = p ? p+1 : _filename;
 463 #else
 464          const char *file = _filename;
 465 #endif
 466          size_t len = strlen(file);
 467          size_t buflen = sizeof(buf);
 468 
 469          strncpy(buf, file, buflen);
 470          if (len + 10 < buflen) {
 471            sprintf(buf + len, ":%d", _lineno);
 472          }
 473          st->print(" (%s)", buf);
 474        } else {
 475          st->print(" (0x%x)", _id);
 476        }
 477      }
 478 
 479   STEP(30, "(printing current thread and pid)")
 480 
 481      // process id, thread id
 482      st->print(", pid=%d", os::current_process_id());
 483      st->print(", tid=" UINTX_FORMAT, os::current_thread_id());
 484      st->cr();
 485 
 486   STEP(40, "(printing error message)")
 487 
 488      if (should_report_bug(_id)) {  // already printed the message.
 489        // error message
 490        if (_detail_msg) {
 491          st->print_cr("#  %s: %s", _message ? _message : "Error", _detail_msg);
 492        } else if (_message) {
 493          st->print_cr("#  Error: %s", _message);




 446      // Is it an OS exception/signal?
 447      if (os::exception_name(_id, buf, sizeof(buf))) {
 448        st->print("%s", buf);
 449        st->print(" (0x%x)", _id);                // signal number
 450        st->print(" at pc=" PTR_FORMAT, _pc);
 451      } else {
 452        if (should_report_bug(_id)) {
 453          st->print("Internal Error");
 454        } else {
 455          st->print("Out of Memory Error");
 456        }
 457        if (_filename != NULL && _lineno > 0) {
 458 #ifdef PRODUCT
 459          // In product mode chop off pathname?
 460          char separator = os::file_separator()[0];
 461          const char *p = strrchr(_filename, separator);
 462          const char *file = p ? p+1 : _filename;
 463 #else
 464          const char *file = _filename;
 465 #endif
 466          st->print(" (%s:%d)", file, _lineno);







 467        } else {
 468          st->print(" (0x%x)", _id);
 469        }
 470      }
 471 
 472   STEP(30, "(printing current thread and pid)")
 473 
 474      // process id, thread id
 475      st->print(", pid=%d", os::current_process_id());
 476      st->print(", tid=" UINTX_FORMAT, os::current_thread_id());
 477      st->cr();
 478 
 479   STEP(40, "(printing error message)")
 480 
 481      if (should_report_bug(_id)) {  // already printed the message.
 482        // error message
 483        if (_detail_msg) {
 484          st->print_cr("#  %s: %s", _message ? _message : "Error", _detail_msg);
 485        } else if (_message) {
 486          st->print_cr("#  Error: %s", _message);


< prev index next >