ZIP753163e1-3061-4268-9b8f-f16e19e718b9.zip 839.56KB

2403_86073403需要积分:7(1积分=1元)

资源文件列表:

753163e1-3061-4268-9b8f-f16e19e718b9.zip 大约有3个文件
  1. attachment/
  2. attachment/libc-2.27.so 1.94MB
  3. attachment/of.c 2.41KB

资源介绍:

753163e1-3061-4268-9b8f-f16e19e718b9.zip
#include<stdlib.h> #include<stdio.h> #include<unistd.h> #define NUM 0x10 char* chunks[NUM]; unsigned long cookie; #define SIZE 0x100 void init_io(){ setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); setvbuf(stderr, 0, 2, 0); int fd = open("/dev/urandom", 0); if(fd == -1){ exit(-1); } read(fd, &cookie, 8); close(fd); } unsigned long get_int(){ unsigned long res; scanf("%ld", &res); return res; } void allocate(){ unsigned long idx; printf("Index: "); idx = get_int(); if(idx >= NUM){ return ; } char* buf = malloc(SIZE); if(buf == NULL){ puts("allocate failed"); return; } chunks[idx] = buf; unsigned long* p = chunks[idx] + SIZE - 8; *p = cookie; puts("Done!"); } void delete(){ unsigned long idx; printf("Index: "); idx = get_int(); if(idx >= NUM || chunks[idx] == NULL){ return ; } unsigned long* p = chunks[idx] + SIZE - 8; if(*p != cookie) return; *p = 0; free(chunks[idx]); } void show(){ unsigned long idx; printf("Index: "); idx = get_int(); if(idx >= NUM || chunks[idx] == NULL){ return ; } unsigned long* p = chunks[idx] + SIZE - 8; if(*p != cookie) return; write(1, "Content: ", strlen("Content: ")); write(1, chunks[idx], SIZE - 8); write(1, "\n", 1); } void edit(){ unsigned long idx; printf("Index: "); idx = get_int(); if(idx >= NUM || chunks[idx] == NULL){ return ; } unsigned long* p = chunks[idx] + SIZE - 8; if(*p != cookie) return; printf("Content: "); read(0, chunks[idx], SIZE); } void menu(){ puts("1. allocate"); puts("2. edit"); puts("3. show"); puts("4. delete"); puts("5. exit"); printf("Your choice: "); } int main(){ init_io(); puts("Made on Ubuntu 18.04"); while(1){ menu(); unsigned long choice = get_int(); switch(choice){ case 1: allocate(); break; case 2: edit(); break; case 3: show(); break; case 4: delete(); break; case 5: exit(0); break; default: puts("Unknown"); break; } } return 0; }
100+评论
captcha
    类型标题大小时间
    ZIP产品经理交互设计指南,压缩包里的教程也是rp文件7.03MB6月前
    ZIP短视频运营课,短视频+模板+矩阵+直播,一套同城短视频打法13.16KB6月前
    ZIP抖音直播小游戏:小白轻松日入1k+保姆级教学34.6MB6月前
    ZIPjava swing项目仓库管理系统mysql数据库-java课程设计毕业设计期末大作业3.83MB6月前
    ZIP数字电路课件for students(V3.0).zip9.98MB6月前
    ZIP系统源码大学数据库课程设计实验课实现内容18.63MB6月前
    ZIPnode.js项目,一个慈善系统项目 有关慈善活动捐款等17.99MB6月前
    ZIPnotes11111.zip3.07MB6月前