Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 69209 Details for
Bug 68263
app-text/recode-3.6 - recode_string() clobbers out-of-bounds memory
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
More agressive test program
test.c (text/plain), 1.59 KB, created by
Ken Pizzini
on 2005-09-25 04:22:42 UTC
(
hide
)
Description:
More agressive test program
Filename:
MIME Type:
Creator:
Ken Pizzini
Created:
2005-09-25 04:22:42 UTC
Size:
1.59 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <stdbool.h> >#include <unistd.h> >#include <fcntl.h> >#include <locale.h> >#include <recode.h> > >#define LOOPMAX 1500 >#define ERRMAX 10 >#define STRMAX 512 > >static void >die(const char *str) >{ > perror(str); > exit(1); >} > >char * >gentext(void) >{ > int len = 1+lrand48()%STRMAX; > char *buf = malloc(len); > char *p = buf; > int i; > > if (!buf) > die("malloc failure"); > for (i=0; i<len; ++i) { > static char alphabet[] = > "abcdefghijklmnopqrstuvwxyz" > "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > "+/.. . .. 1" > ; > *p++ = alphabet[lrand48()%(sizeof(alphabet)-1)]; > } > *p = '\0'; > return buf; >} > >static void >test_harness(RECODE_REQUEST request) >{ > int errcnt = 0; > int i; > > for (i=0; i<LOOPMAX; ++i) { > char *text = gentext(); > char *output; > output = recode_string(request, text); > if (!output) > die("recode failure"); > if (strcmp(output, text) != 0) { > printf("iteration %d: <<%s>> != <<%s>>\n", text, output); > if (++errcnt > ERRMAX) > exit(1); > } > free(output); > free(text); > } >} > >static void >init_random(void) >{ > long seed; > int f = open("/dev/urandom", O_RDONLY); > if (f == -1) > die("init_random"); > read(f, &seed, sizeof seed); > close(f); > srand48(seed); >} > >int >main(int argc, char **argv) >{ > RECODE_OUTER outer = recode_new_outer(true); > RECODE_REQUEST request = recode_new_request(outer); > > setlocale(LC_ALL,""); > recode_scan_request(request, "UTF-8..ISO-8859-1"); > init_random(); > test_harness(request); > > recode_delete_request(request); > recode_delete_outer(outer); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 68263
:
42245
|
69209
|
487884