首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >memcpy-- memcpy之后内核崩溃

memcpy-- memcpy之后内核崩溃
EN

Stack Overflow用户
提问于 2011-05-18 00:16:47
回答 1查看 1.9K关注 0票数 0

我需要帮助我正在尝试使用memcpy在内核空间复制一个头文件,但是屏幕变黑了,看起来不像我的memcpy。请谁来帮帮我。

代码语言:javascript
复制
        remaining = ntohs(iphead->tot_len) - 20; //(remaining = total size of ip packet - size of meta header)
 while(remaining != 0) {
    currentHead = (struct iphdr *) pos; //save the first 'real' header
    if(currentHead == NULL)
        goto fail;
    nskb = dev_alloc_skb(ntohs(currentHead->tot_len) + MAC_LENGTH );
    if(nskb == NULL)
        goto fail; //We can't allocate that memory so we leave
    if(nskb->tail + MAC_LENGTH + ntohs(currentHead->tot_len) <= nskb->end){ 

        nskb->data = skb_put(nskb, (MAC_LENGTH + ntohs(currentHead->tot_len))); // allocated all the memory we need
        memcpy(nskb->data,(*skb)->mac_header, MAC_LENGTH); //Put the mac header in place
        nskb->mac_header = nskb->data; //Save the mac header location
        nskb->network_header = nskb->data + MAC_LENGTH; //Move the pointer to where the network header will be
        memcpy(nskb->network_header, pos, ntohs(currentHead->tot_len)); //save the ip + payload

        nskb->data = nskb->network_header;
EN

回答 1

Stack Overflow用户

发布于 2011-05-18 00:25:36

pos真的有效吗?哪个memcpy给你带来了问题?我猜这是Linux内核吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6033912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档