Changeset f85ed4b in mainline for uspace/srv/net/dnsres/dns_msg.c


Ignore:
Timestamp:
2012-08-12T17:51:26Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08a6382
Parents:
adae30d
Message:

Fixes: initialize off, increment lsize.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/dnsres/dns_msg.c

    radae30d rf85ed4b  
    4545#define NAME  "dnsres"
    4646
     47#include <stdio.h>
    4748static int dns_name_encode(char *name, uint8_t *buf, size_t buf_size,
    4849    size_t *act_size)
     
    5556        pi = 0;
    5657        di = 1;
    57 
     58        off = 0;
     59
     60        printf("dns_name_encode(name='%s', buf=%p, buf_size=%zu, act_size=%p\n",
     61            name, buf, buf_size, act_size);
    5862        lsize = 0;
    5963        while (true) {
     64                printf("off=%zu\n", off);
    6065                c = str_decode(name, &off, STR_NO_LIMIT);
     66                printf("c=%d\n", (int)c);
    6167                if (c > 127) {
    6268                        /* Non-ASCII character */
     69                        printf("non-ascii character\n");
    6370                        return EINVAL;
    6471                }
     
    6673                if (c == '.' || c == '\0') {
    6774                        /* Empty string, starting with period or two consecutive periods. */
    68                         if (lsize == 0)
     75                        if (lsize == 0) {
     76                                printf("empty token\n");
    6977                                return EINVAL;
     78                        }
    7079
    7180                        if (lsize > DNS_LABEL_MAX_SIZE) {
    7281                                /* Label too long */
     82                                printf("label too long\n");
    7383                                return EINVAL;
    7484                        }
     
    8393                        ++di;
    8494                } else {
     95                        ++lsize;
    8596                        if (buf != NULL && di < buf_size)
    8697                                buf[di++] = c;
     
    116127
    117128        *act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t);
     129        if (buf == NULL)
     130                return EOK;
     131
    118132        di = name_size;
    119133
Note: See TracChangeset for help on using the changeset viewer.