Changeset 451

Show
Ignore:
Timestamp:
02/12/05 15:53:11 (8 years ago)
Author:
minaguib
Message:

Insignificant

Location:
trunk/wifidog/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/src/firewall.c

    r449 r451  
    110110{ 
    111111    FILE           *proc; 
    112     char            *ip, *mac; 
     112         char ip[16]; 
     113         char mac[18]; 
    113114         char * reply; 
    114115 
     
    116117        return NULL; 
    117118    } 
    118     if (!(ip = malloc(16))) { 
    119                  debug(LOG_CRIT, "Cannot allocate 16 bytes of memory for IP, Banzai!"); 
    120                  exit(1); 
    121          } 
    122     if (!(mac = malloc(18))) { 
    123                  debug(LOG_CRIT, "Cannot allocate 18 bytes of memory for MAC, Banzai!"); 
    124                  exit(1); 
    125          } 
    126119 
    127120    /* Skip first line */ 
    128121         while (!feof(proc) && fgetc(proc) != '\n'); 
    129122 
    130          /* Find ip, put mac in reply */ 
     123         /* Find ip, copy mac in reply */ 
    131124         reply = NULL; 
    132125    while (!feof(proc) && (fscanf(proc, " %15[0-9.] %*s %*s %17[A-F0-9:] %*s %*s", ip, mac) == 2)) { 
    133126                  if (strcmp(ip, req_ip) == 0) { 
    134                                 reply = mac; 
     127                                reply = strdup(mac); 
    135128                                break; 
    136129                  } 
    137130    } 
    138  
    139     free(ip); 
    140          if (!reply) 
    141                  free(mac); 
    142131 
    143132    fclose(proc); 
  • trunk/wifidog/src/ping_thread.c

    r450 r451  
    193193        } 
    194194        if ((fh = fopen("/proc/loadavg", "r"))) { 
    195                 fscanf(fh, "%*s %f", &sys_load); 
     195                fscanf(fh, "%f", &sys_load); 
    196196                fclose(fh); 
    197197        } 
    198198 
    199         snprintf(request, sizeof(request) - 1, "GET %sping/?gw_id=%s&sys_uptime=%lu&sys_memfree=%u&sys_load=%f HTTP/1.0\n" 
     199        /* 
     200         * Prep & send request 
     201         */ 
     202        snprintf(request, sizeof(request) - 1, "GET %sping/?gw_id=%s&sys_uptime=%lu&sys_memfree=%u&sys_load=%.2f HTTP/1.0\n" 
    200203                        "User-Agent: WiFiDog %s\n" 
    201204                        "Host: %s\n" 
  • trunk/wifidog/src/util.c

    r426 r451  
    103103        h_addr = (struct in_addr *)malloc(sizeof(struct in_addr)); 
    104104         
    105         if (h_addr == NULL) 
    106                 return NULL; 
     105        if (h_addr == NULL) { 
     106                debug(LOG_CRIT, "Failed to allocate memory for in_addr"); 
     107                exit(1); 
     108        } 
    107109         
    108110        LOCK_GHBN();