Mageia Bugzilla – Attachment 9919 Details for
Bug 22433
glibc new security issues CVE-2017-16997 and CVE-2018-1000001
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
memusage example from man pages
memorex.c (text/plain), 584 bytes, created by
Len Lawrence
on 2018-01-22 10:11:55 CET
(
hide
)
Description:
memusage example from man pages
Filename:
MIME Type:
Creator:
Len Lawrence
Created:
2018-01-22 10:11:55 CET
Size:
584 bytes
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> > >#define CYCLES 20 > >int >main(int argc, char *argv[]) >{ > int i, j; > int *p; > > printf("malloc: %zd\n", sizeof(int) * 100); > p = malloc(sizeof(int) * 100); > for (i = 0; i < CYCLES; i++) { > if (i < CYCLES / 2) > j = i; > else > j--; > printf("realloc: %zd\n", sizeof(int) * (j * 50 + 110)); > p = realloc(p, sizeof(int) * (j * 50 + 100)); > printf("realloc: %zd\n", sizeof(int) * ((j+1) * 150 + 110)); > p = realloc(p, sizeof(int) * ((j + 1) * 150 + 110)); > } > free(p); > exit(EXIT_SUCCESS); >} >
#include <stdio.h> #include <stdlib.h> #define CYCLES 20 int main(int argc, char *argv[]) { int i, j; int *p; printf("malloc: %zd\n", sizeof(int) * 100); p = malloc(sizeof(int) * 100); for (i = 0; i < CYCLES; i++) { if (i < CYCLES / 2) j = i; else j--; printf("realloc: %zd\n", sizeof(int) * (j * 50 + 110)); p = realloc(p, sizeof(int) * (j * 50 + 100)); printf("realloc: %zd\n", sizeof(int) * ((j+1) * 150 + 110)); p = realloc(p, sizeof(int) * ((j + 1) * 150 + 110)); } free(p); exit(EXIT_SUCCESS); }
View Attachment As Raw
Actions:
View
Attachments on
bug 22433
: 9919