~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to iris/src/jdns/jdns_sys.c

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
                unsigned char c = fgetc(f);
253
253
                if(feof(f))
254
254
                {
255
 
                        jdns_free(buf);
256
 
                        return 0;
 
255
                        if(at > 0)
 
256
                        {
 
257
                                // if we read at least one char, take it as a
 
258
                                //   line
 
259
                                break;
 
260
                        }
 
261
                        else
 
262
                        {
 
263
                                jdns_free(buf);
 
264
                                return 0;
 
265
                        }
257
266
                }
258
267
                if(c == '\n')
259
268
                        break;
556
565
        return params;
557
566
}
558
567
 
559
 
static void apply_win_hosts_file(jdns_dnsparams_t *a)
 
568
static void apply_hosts_var_filepath(jdns_dnsparams_t *a, const char *envvar, const char *path)
560
569
{
561
 
        jdns_string_t *p;
 
570
        jdns_string_t *e;
562
571
        char *str;
563
 
        int len;
 
572
        int elen, plen;
564
573
 
565
 
        p = jdns_getenv("WINDIR");
566
 
        if(!p)
 
574
        e = jdns_getenv(envvar);
 
575
        if(!e)
567
576
                return;
568
 
        len = strlen((char *)p->data);
569
 
        str = (char *)jdns_alloc(len + 100); // should be enough
570
 
        memcpy(str, p->data, len);
571
 
        jdns_string_delete(p);
572
 
        jdns_strcpy(str + len, "\\system32\\drivers\\etc\\hosts"); // winnt+
573
 
        apply_hosts_file(a, str);
574
 
        jdns_strcpy(str + len, "\\hosts"); // win9x
 
577
        elen = strlen((char *)e->data);
 
578
        plen = strlen(path);
 
579
        str = (char *)jdns_alloc(elen + plen + 1);
 
580
        memcpy(str, e->data, elen);
 
581
        jdns_string_delete(e);
 
582
 
 
583
        jdns_strcpy(str + elen, path);
575
584
        apply_hosts_file(a, str);
576
585
        jdns_free(str);
577
586
}
578
587
 
 
588
static void apply_win_hosts_file(jdns_dnsparams_t *a)
 
589
{
 
590
        // windows 64-bit
 
591
        apply_hosts_var_filepath(a, "SystemRoot", "\\SysWOW64\\drivers\\etc\\hosts");
 
592
 
 
593
        // winnt+
 
594
        apply_hosts_var_filepath(a, "SystemRoot", "\\system32\\drivers\\etc\\hosts");
 
595
 
 
596
        // win9x
 
597
        apply_hosts_var_filepath(a, "WINDIR", "\\hosts");
 
598
}
 
599
 
579
600
static jdns_dnsparams_t *dnsparams_get_win()
580
601
{
581
602
        int n;
738
759
                struct sockaddr_in6 *sa6;
739
760
 
740
761
#ifdef USE_EXTEXT
 
762
                // seems _ext.ext can be null in some cases...
 
763
                if(RESVAR._u._ext.ext == NULL)
 
764
                        break;
 
765
 
741
766
                sa6 = ((struct sockaddr_in6 *)RESVAR._u._ext.ext) + n;
742
767
#else
743
768
                sa6 = RESVAR._u._ext.nsaddrs[n];