summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Expand)AuthorAgeFilesLines
* Rename FMODE_STRIP_BOM to FMODE_SETENC_BY_BOM.naruse2009-08-211-1/+1
* \d, \s and \w are now non Unicode class. [ruby-dev:39026]naruse2009-08-151-0/+8
* * include/ruby/ruby.h (rb_check_safe_str): deprecated.nobu2009-08-141-1/+1
* * class.c (rb_define_class_id_under, rb_define_module_id_under):nobu2009-08-121-0/+2
* * include/ruby/intern.h (rb_path2class): no deprecation.nobu2009-08-101-1/+1
* * gc.c: reject unused longlife gc.nari2009-08-102-2/+1
* * marshal.c (class2path, w_unique, w_extended, w_class, w_uclass):nobu2009-08-091-1/+2
* Warn duplicated characters in character class of regexp. [ruby-core:24593]naruse2009-08-041-0/+1
* * insns.def (defineclass): preserve encoding of class/modulenobu2009-07-301-0/+1
* * include/ruby/intern.h (rb_*str_new_cstr, rb_str_buf_new_cstr),nobu2009-07-271-10/+10
* * include/ruby/defines.h [__SYMBIAN32__]: defined TRUE and FALSE to match cha...azav2009-07-251-0/+5
* * win32/win32.[ch] (recvmsg, sendmsg): new functions to support recvmsg/usa2009-07-211-0/+17
* * include/ruby/defines.h (TRUE, FALSE): for internal use.nobu2009-07-181-0/+12
* * random.c (rb_random_{int32,real,bytes,int}): added functions fornobu2009-07-181-1/+5
* * include/ruby/win32.h: include winsock headers in extern "C++" forusa2009-07-172-7/+7
* * bignum.c (rb_big_new, rb_bigzero_p), range.c (rb_range_values):nobu2009-07-161-0/+3
* * method.h, vm_core.h: add rb_method_entry_t. Remove nodes aroundko12009-07-151-1/+0
* * include/ruby/ruby.h (rb_obj_{untrust,untrusted,trust}): addednobu2009-07-101-0/+3
* Set encoding and strip bom when modeenc string is "r:foo-bom" [ruby-dev:37236]naruse2009-07-091-0/+1
* * include/ruby/ruby.h:ko12009-07-071-9/+9
* * error.c (rb_typed_struct_is_kind_of): new function to see if thenobu2009-07-071-0/+2
* * error.c (rb_check_typed_struct): new function to check typednobu2009-07-071-0/+6
* * include/ruby/intern.h (rb_time_num_new): declared.akr2009-07-011-0/+1
* * re.c (reg_match_pos): adjust offset based on characters, notmatz2009-06-301-0/+1
* * include/ruby/oniguruma.h, include/ruby/re.h, re.c, regcomp.c,nobu2009-06-302-7/+7
* * file.c (rb_get_path_check): check with given safe level.nobu2009-06-231-0/+1
* * file.c (rb_find_file_ext, rb_find_file): no needs to expandnobu2009-06-231-0/+3
* * st.c, include/ruby/st.h (st_memsize): added. This function returnsko12009-06-161-0/+1
* * include/ruby/ruby.h: New structure RTypedData, added.ko12009-06-161-0/+30
* * thread.c: rename functions which require a parameterko12009-06-081-2/+0
* * include/ruby/intern.h (rb_exc_new2): optimization for literal.nobu2009-06-011-0/+6
* * st.c (st_insert2): new function with processing new key,matz2009-05-271-0/+1
* * common.mk (bignum.o, numeric.o): depend on util.h.nobu2009-05-261-2/+16
* * include/ruby/ruby.h (FilePathValue): prevent from GC.nobu2009-05-251-1/+1
* * include/ruby/ruby.h (NUM2LONG): added GCC specific optimization.nobu2009-05-251-2/+8
* * thread.c (rb_exec_recursive_paired): new function for propernobu2009-05-241-0/+1
* * include/ruby/ruby.h (RB_EVENT_HOOKS_HAVE_CALLBACK_DATA):nobu2009-05-211-0/+1
* * include/ruby/ruby.h (rb_long2int, RARRAY_LENINT): check long tonobu2009-05-201-0/+19
* * encoding.c (rb_enc_fast_mbclen): faster mbclen for strings knownmatz2009-05-201-0/+3
* * encoding.c (rb_enc_codepoint_len): combine rb_enc_codepoint()matz2009-05-191-1/+7
* * gc.c: add longlife garbage collection. [ruby-dev:38423]nari2009-05-132-1/+2
* * include/ruby/version.h: extracted the extensions interface andnobu2009-05-131-0/+61
* * string.c, include/ruby/encoding.h: fixed types.nobu2009-05-071-2/+2
* * eval.c (ruby_cleanup): the order of local variables on stack isnobu2009-04-191-2/+2
* * class.c (rb_define_method_id): use rb_define_notimplement_method_idakr2009-04-161-0/+2
* * include/ruby/intern.h (rb_fd_resize): does nothing on Win32.nobu2009-04-051-0/+1
* * include/ruby/intern.h (Init_stack): moved.nobu2009-04-051-1/+1
* * include/ruby/intern.h (RB_NUM_COERCE_FUNCS_NEED_OPID): macro tonobu2009-04-041-0/+1
* * thread.c (rb_thread_fd_select): new function to call selectmatz2009-04-011-0/+2
* * io.c (rb_mWaitReadable): defined.akr2009-03-191-0/+3
offset; char *p; if (lseek(isofd, (off_t)(16L * 2048L), SEEK_SET) == -1) return ((long long)-1); offset = (16L * 2048L); for (;1;) { if (read(isofd, buf, 2048) <= 0) return ((long long)-1); if (buf[0] == 1) /* found primary volume descriptor */ break; else if (buf[0] == 255) /* hit end and didn't find primary volume descriptor */ return ((long long)-1); offset += 2048L; } /* read out md5sum */ memcpy(buf2, buf + APPDATA_OFFSET, 512); buf2[511] = '\0'; *supported = 0; md5fnd = 0; skipfnd = 0; fragsumfnd = 0; fragcntfnd = 0; supportedfnd = 0; loc = 0; while (loc < 512) { if (!strncmp(buf2 + loc, "ISO MD5SUM = ", 13)) { /* make sure we dont walk off end */ if ((loc + 32) > 511) return -1; memcpy(mediasum, buf2 + loc + 13, 32); mediasum[32] = '\0'; md5fnd = 1; logMessage(INFO, "MD5SUM -> %s", mediasum); loc += 45; for (p=buf2+loc; *p != ';' && loc < 512; p++, loc++); } else if (!strncmp(buf2 + loc, "SKIPSECTORS = ", 14)) { char *errptr; /* make sure we dont walk off end */ if ((loc + 14) > 511) return -1; loc = loc + 14; for (p=tmpbuf; buf2[loc] != ';' && loc < 512; p++, loc++) *p = buf2[loc]; *p = '\0'; /* logMessage(DEBUGLVL, "SKIPSECTORS -> |%s|", tmpbuf); */ *skipsectors = strtol(tmpbuf, &errptr, 10); if (errptr && *errptr) { logMessage(ERROR, "Could not parse |%s|", errptr); return -1; } else { logMessage(INFO, "skipsectors = %d", *skipsectors); skipfnd = 1; } for (p=buf2+loc; *p != ';' && loc < 512; p++, loc++); } else if (!strncmp(buf2 + loc, "RHLISOSTATUS=1", 14)) { *supported = 1; supportedfnd = 1; logMessage(INFO, "supported = 1"); for (p=buf2+loc; *p != ';' && loc < 512; p++, loc++); } else if (!strncmp(buf2 + loc, "RHLISOSTATUS=0", 14)) { *supported = 0; supportedfnd = 1; logMessage(INFO, "supported = 0"); for (p=buf2+loc; *p != ';' && loc < 512; p++, loc++); } else if (!strncmp(buf2 + loc, "FRAGMENT SUMS = ", 16)) { /* make sure we dont walk off end */ if ((loc + FRAGMENT_SUM_LENGTH) > 511) return -1; memcpy(fragmentsums, buf2 + loc + 16, FRAGMENT_SUM_LENGTH); fragmentsums[FRAGMENT_SUM_LENGTH] = '\0'; fragsumfnd = 1; loc += FRAGMENT_SUM_LENGTH + 16; for (p=buf2+loc; *p != ';' && loc < 512; p++, loc++); } else if (!strncmp(buf2 + loc, "FRAGMENT COUNT = ", 17)) { char *errptr; /* make sure we dont walk off end */ if ((loc + 17) > 511) return -1; loc = loc + 17; for (p=tmpbuf; buf2[loc] != ';' && loc < 512; p++, loc++) *p = buf2[loc]; *p = '\0'; *fragmentcount = strtol(tmpbuf, &errptr, 10); if (errptr && *errptr) { return -1; } else { fragcntfnd = 1; } for (p=buf2+loc; *p != ';' && loc < 512; p++, loc++); } else { loc++; } if ((skipfnd & md5fnd & fragsumfnd & fragcntfnd) & supportedfnd) break; } if (!(skipfnd & md5fnd)) return -1; /* get isosize */ *isosize = (buf[SIZE_OFFSET]*0x1000000+buf[SIZE_OFFSET+1]*0x10000 + buf[SIZE_OFFSET+2]*0x100 + buf[SIZE_OFFSET+3]) * 2048LL; return offset; } /* returns -1 if no checksum encoded in media, 0 if no match, 1 if match */ /* mediasum is the sum encoded in media, computedsum is one we compute */ /* both strings must be pre-allocated at least 33 chars in length */ static int checkmd5sum(int isofd, char *mediasum, char *computedsum, checkCallback cb, void *cbdata) { int nread; int i, j; int appdata_start_offset, appdata_end_offset; int nattempt; int skipsectors; int supported; int current_fragment = 0; int previous_fragment = 0; unsigned int bufsize = 32768; unsigned char md5sum[16]; unsigned char fragmd5sum[16]; unsigned int len; unsigned char *buf; long long isosize, offset, pvd_offset, apoff; char fragmentsums[FRAGMENT_SUM_LENGTH+1]; char thisfragsum[FRAGMENT_SUM_LENGTH+1]; long long fragmentcount = 0; MD5_CTX md5ctx, fragmd5ctx; if ((pvd_offset = parsepvd(isofd, mediasum, &skipsectors, &isosize, &supported, fragmentsums, &fragmentcount)) < 0) return -1; /* rewind, compute md5sum */ lseek(isofd, 0L, SEEK_SET); MD5_Init(&md5ctx); offset = 0; apoff = pvd_offset + APPDATA_OFFSET; buf = malloc(bufsize * sizeof(unsigned char)); while (offset < isosize - skipsectors*2048) { nattempt = MIN(isosize - skipsectors*2048 - offset, bufsize); nread = read(isofd, buf, nattempt); if (nread <= 0) break; if (nread > nattempt) { fprintf(stderr, "Warning: read got more data than requested\n"); nread = nattempt; lseek(isofd, offset+nread, SEEK_SET); } /* overwrite md5sum we implanted with original data */ if (offset < apoff && offset+nread >= apoff) { appdata_start_offset = apoff - offset; appdata_end_offset = MIN(appdata_start_offset+MIN(nread, 512), offset + nread - apoff); len = appdata_end_offset - appdata_start_offset; memset(buf+appdata_start_offset, ' ', len); } else if (offset >= apoff && offset+nread < apoff + 512) { appdata_start_offset = 0; appdata_end_offset = nread; len = appdata_end_offset - appdata_start_offset; memset(buf+appdata_start_offset, ' ', len); } else if (offset < apoff + 512 && offset+nread >= apoff + 512) { appdata_start_offset = 0; appdata_end_offset = apoff + 512 - offset; len = appdata_end_offset - appdata_start_offset; memset(buf+appdata_start_offset, ' ', len); } MD5_Update(&md5ctx, buf, nread); if (fragmentcount) { current_fragment = offset * (fragmentcount+1) / (isosize - skipsectors*2048); /* if we're onto the next fragment, calculate the previous sum and check */ if ( current_fragment != previous_fragment ) { memcpy(&fragmd5ctx, &md5ctx, sizeof(MD5_CTX)); MD5_Final(fragmd5sum, &fragmd5ctx); *computedsum = '\0'; j = (current_fragment-1)*FRAGMENT_SUM_LENGTH/fragmentcount; for (i=0; i<FRAGMENT_SUM_LENGTH/fragmentcount; i++) { char tmpstr[2]; snprintf(tmpstr, 2, "%01x", fragmd5sum[i]); strncat(computedsum, tmpstr, 2); thisfragsum[i] = fragmentsums[j++]; } thisfragsum[j] = '\0'; /* printf("\nFragment [%i]: %s ?= %s\n", previous_fragment, computedsum, thisfragsum); */ previous_fragment = current_fragment; /* Exit immediatiately if current fragment sum is incorrect */ if (strcmp(thisfragsum, computedsum) != 0) { free(buf); return 0; } } } offset = offset + nread; if (cb) cb(cbdata, offset); } if (cb) cb(cbdata, isosize); sleep(1); free(buf); MD5_Final(md5sum, &md5ctx); *computedsum = '\0'; for (i=0; i<16; i++) { char tmpstr[4]; snprintf (tmpstr, 4, "%02x", md5sum[i]); strncat(computedsum, tmpstr, 2); } if (strcmp(mediasum, computedsum)) return 0; else return 1; } static void readCB(void *co, long long pos) { struct progressCBdata *data = co; static int tick = 0; char tickmark[2] = "-"; char * ticks = "-\\|/"; newtScaleSet(data->scale, pos); tick++; if (tick > 399) tick = 0; *tickmark = ticks[tick / 100]; newtLabelSetText(data->label, tickmark); newtRefresh(); } static int doMediaCheck(int isofd, char *descr, char *mediasum, char *computedsum, long long *isosize, int *supported) { struct progressCBdata data; newtComponent t, f, scale, label; int rc; int dlen; int llen; int skipsectors; char tmpstr[1024]; long long fragmentcount = 0; char fragmentsums[FRAGMENT_SUM_LENGTH+1]; if (parsepvd(isofd, mediasum, &skipsectors, isosize, supported, fragmentsums, &fragmentcount) < 0) { newtWinMessage(_("Error"), _("OK"), _("Unable to read the disc checksum from the " "primary volume descriptor. This probably " "means the disc was created without adding the " "checksum.")); return -1; } if (descr) snprintf(tmpstr, sizeof(tmpstr), _("Checking \"%s\"..."), descr); else snprintf(tmpstr, sizeof(tmpstr), _("Checking media now...")); dlen = strlen(tmpstr); if (dlen > 65) dlen = 65; newtCenteredWindow(dlen+8, 6, _("Media Check")); t = newtTextbox(1, 1, dlen+4, 3, NEWT_TEXTBOX_WRAP); newtTextboxSetText(t, tmpstr); llen = strlen(tmpstr); label = newtLabel(llen+1, 1, "-"); f = newtForm(NULL, NULL, 0); newtFormAddComponent(f, t); scale = newtScale(3, 3, dlen, *isosize); newtFormAddComponent(f, scale); newtDrawForm(f); newtRefresh(); data.scale = scale; data.label = label; rc = checkmd5sum(isofd, mediasum, computedsum, readCB, &data); newtFormDestroy(f); newtPopWindow(); return rc; } int mediaCheckFile(char *file, char *descr) { int isofd; int rc; int supported; char *result; char mediasum[33], computedsum[33]; char tmpstr[512]; char descrstr[256]; long long isosize; newtComponent t, f; isofd = open(file, O_RDONLY); if (isofd < 0) { newtWinMessage(_("Error"), _("OK"), _("Unable to find install image " "%s"), file); return -1; } supported = 0; rc = doMediaCheck(isofd, descr, mediasum, computedsum, &isosize, &supported); close(isofd); if (rc == 0) { result = _("FAIL.\n\n" "The image which was just tested has errors. " "This could be due to a " "corrupt download or a bad disc. " "If applicable, please clean the disc " "and try again. If this test continues to fail you " "should not continue the install."); logMessage(ERROR, "mediacheck: %s (%s) FAILED", file, descr); logMessage(ERROR, "value of supported iso flag is %d", supported); } else if (rc > 0) { result = _("PASS.\n\nIt is OK to install from this media."); logMessage(INFO, "mediacheck: %s (%s) PASSED", file, descr); logMessage(INFO, "value of supported iso flag is %d", supported); } else { result = _("NA.\n\nNo checksum information available, unable to verify media."); logMessage(WARNING, "mediacheck: %s (%s) has no checksum info", file, descr); } newtCenteredWindow(60, 20, _("Media Check Result")); t = newtTextbox(4, 1, 56, 18, NEWT_TEXTBOX_WRAP); if (descr) snprintf(descrstr, sizeof(descrstr), _("of the image:\n\n%s\n\n"), descr); else descrstr[0] = '\0'; snprintf(tmpstr, sizeof(tmpstr), _("The media check %sis complete, and " "the result is: %s\n"), descrstr, result); newtTextboxSetText(t, tmpstr); f = newtForm(NULL, NULL, 0); newtFormAddComponent(f, t); newtFormAddComponent(f, newtButton(26, 15, _("OK"))); newtRunForm(f); newtFormDestroy(f); newtPopWindow(); return rc; } #ifdef TESTING int main(int argc, char **argv) { int rc; if (argc < 2) { printf("Usage: checkisomd5 <isofilename>\n\n"); exit(1); } newtInit(); newtCls(); rc = mediaCheckFile(argv[1], "TESTING"); newtFinished(); exit (0); } #endif