diff options
| -rw-r--r-- | networking/dnsd.c | 26 | ||||
| -rw-r--r-- | util-linux/mount.c | 38 |
2 files changed, 35 insertions, 29 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c index 71f50423d..6a866f1d7 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
| @@ -110,7 +110,7 @@ static void undot(uint8_t * rip) | |||
| 110 | * Read one line of hostname/IP from file | 110 | * Read one line of hostname/IP from file |
| 111 | * Returns 0 for each valid entry read, -1 at EOF | 111 | * Returns 0 for each valid entry read, -1 at EOF |
| 112 | * Assumes all host names are lower case only | 112 | * Assumes all host names are lower case only |
| 113 | * Hostnames with more than one label is not handled correctly. | 113 | * Hostnames with more than one label are not handled correctly. |
| 114 | * Presently the dot is copied into name without | 114 | * Presently the dot is copied into name without |
| 115 | * converting to a length/string substring for that label. | 115 | * converting to a length/string substring for that label. |
| 116 | */ | 116 | */ |
| @@ -118,32 +118,37 @@ static void undot(uint8_t * rip) | |||
| 118 | static int getfileentry(FILE * fp, struct dns_entry *s) | 118 | static int getfileentry(FILE * fp, struct dns_entry *s) |
| 119 | { | 119 | { |
| 120 | unsigned int a,b,c,d; | 120 | unsigned int a,b,c,d; |
| 121 | char *r, *name; | 121 | char *line, *r, *name; |
| 122 | 122 | ||
| 123 | restart: | 123 | restart: |
| 124 | r = xmalloc_fgets(fp); | 124 | line = r = xmalloc_fgets(fp); |
| 125 | if (!r) | 125 | if (!r) |
| 126 | return -1; | 126 | return -1; |
| 127 | while (*r == ' ' || *r == '\t') { | 127 | while (*r == ' ' || *r == '\t') { |
| 128 | r++; | 128 | r++; |
| 129 | if (!*r || *r == '#' || *r == '\n') | 129 | if (!*r || *r == '#' || *r == '\n') { |
| 130 | free(line); | ||
| 130 | goto restart; /* skipping empty/blank and commented lines */ | 131 | goto restart; /* skipping empty/blank and commented lines */ |
| 132 | } | ||
| 131 | } | 133 | } |
| 132 | name = r; | 134 | name = r; |
| 133 | while (*r != ' ' && *r != '\t') | 135 | while (*r != ' ' && *r != '\t') |
| 134 | r++; | 136 | r++; |
| 135 | *r++ = 0; | 137 | *r++ = '\0'; |
| 136 | if (sscanf(r, "%u.%u.%u.%u", &a, &b, &c, &d) != 4) | 138 | if (sscanf(r, "%u.%u.%u.%u", &a, &b, &c, &d) != 4) { |
| 139 | free(line); | ||
| 137 | goto restart; /* skipping wrong lines */ | 140 | goto restart; /* skipping wrong lines */ |
| 141 | } | ||
| 138 | 142 | ||
| 139 | sprintf(s->ip, "%u.%u.%u.%u", a, b, c, d); | 143 | sprintf(s->ip, "%u.%u.%u.%u", a, b, c, d); |
| 140 | sprintf(s->rip, ".%u.%u.%u.%u", d, c, b, a); | 144 | sprintf(s->rip, ".%u.%u.%u.%u", d, c, b, a); |
| 141 | undot((uint8_t*)s->rip); | 145 | undot((uint8_t*)s->rip); |
| 142 | convname(s->name,(uint8_t*)name); | 146 | convname(s->name, (uint8_t*)name); |
| 143 | 147 | ||
| 144 | if (OPT_verbose) | 148 | if (OPT_verbose) |
| 145 | fprintf(stderr, "\tname:%s, ip:%s\n", &(s->name[1]),s->ip); | 149 | fprintf(stderr, "\tname:%s, ip:%s\n", &(s->name[1]),s->ip); |
| 146 | 150 | ||
| 151 | free(line); | ||
| 147 | return 0; | 152 | return 0; |
| 148 | } | 153 | } |
| 149 | 154 | ||
| @@ -154,14 +159,13 @@ static void dnsentryinit(void) | |||
| 154 | { | 159 | { |
| 155 | FILE *fp; | 160 | FILE *fp; |
| 156 | struct dns_entry *m, *prev; | 161 | struct dns_entry *m, *prev; |
| 157 | prev = dnsentry = NULL; | ||
| 158 | 162 | ||
| 163 | prev = dnsentry = NULL; | ||
| 159 | fp = xfopen(fileconf, "r"); | 164 | fp = xfopen(fileconf, "r"); |
| 160 | 165 | ||
| 161 | while (1) { | 166 | while (1) { |
| 162 | m = xmalloc(sizeof(struct dns_entry)); | 167 | m = xzalloc(sizeof(*m)); |
| 163 | 168 | /*m->next = NULL;*/ | |
| 164 | m->next = NULL; | ||
| 165 | if (getfileentry(fp, m)) | 169 | if (getfileentry(fp, m)) |
| 166 | break; | 170 | break; |
| 167 | 171 | ||
diff --git a/util-linux/mount.c b/util-linux/mount.c index 77382ff51..ee45f01a6 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
| @@ -1386,14 +1386,16 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
| 1386 | 1386 | ||
| 1387 | // Treat fstype "auto" as unspecified. | 1387 | // Treat fstype "auto" as unspecified. |
| 1388 | 1388 | ||
| 1389 | if (mp->mnt_type && !strcmp(mp->mnt_type,"auto")) mp->mnt_type = 0; | 1389 | if (mp->mnt_type && strcmp(mp->mnt_type,"auto") == 0) |
| 1390 | mp->mnt_type = 0; | ||
| 1390 | 1391 | ||
| 1391 | // Might this be an CIFS filesystem? | 1392 | // Might this be an CIFS filesystem? |
| 1392 | 1393 | ||
| 1393 | if (ENABLE_FEATURE_MOUNT_CIFS && | 1394 | if (ENABLE_FEATURE_MOUNT_CIFS |
| 1394 | (!mp->mnt_type || !strcmp(mp->mnt_type,"cifs")) && | 1395 | && (!mp->mnt_type || strcmp(mp->mnt_type,"cifs") == 0) |
| 1395 | (mp->mnt_fsname[0]==mp->mnt_fsname[1] && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\'))) | 1396 | && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\') |
| 1396 | { | 1397 | && mp->mnt_fsname[0]==mp->mnt_fsname[1] |
| 1398 | ) { | ||
| 1397 | struct hostent *he; | 1399 | struct hostent *he; |
| 1398 | char ip[32], *s; | 1400 | char ip[32], *s; |
| 1399 | 1401 | ||
| @@ -1407,7 +1409,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
| 1407 | 1409 | ||
| 1408 | s = strrchr(mp->mnt_fsname, '\\'); | 1410 | s = strrchr(mp->mnt_fsname, '\\'); |
| 1409 | if (s == mp->mnt_fsname+1) goto report_error; | 1411 | if (s == mp->mnt_fsname+1) goto report_error; |
| 1410 | *s = 0; | 1412 | *s = '\0'; |
| 1411 | he = gethostbyname(mp->mnt_fsname+2); | 1413 | he = gethostbyname(mp->mnt_fsname+2); |
| 1412 | *s = '\\'; | 1414 | *s = '\\'; |
| 1413 | if (!he) goto report_error; | 1415 | if (!he) goto report_error; |
| @@ -1434,10 +1436,10 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
| 1434 | 1436 | ||
| 1435 | // Might this be an NFS filesystem? | 1437 | // Might this be an NFS filesystem? |
| 1436 | 1438 | ||
| 1437 | if (ENABLE_FEATURE_MOUNT_NFS && | 1439 | if (ENABLE_FEATURE_MOUNT_NFS |
| 1438 | (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) && | 1440 | && (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) |
| 1439 | strchr(mp->mnt_fsname, ':') != NULL) | 1441 | && strchr(mp->mnt_fsname, ':') != NULL |
| 1440 | { | 1442 | ) { |
| 1441 | rc = nfsmount(mp, vfsflags, filteropts); | 1443 | rc = nfsmount(mp, vfsflags, filteropts); |
| 1442 | goto report_error; | 1444 | goto report_error; |
| 1443 | } | 1445 | } |
| @@ -1445,8 +1447,9 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
| 1445 | // Look at the file. (Not found isn't a failure for remount, or for | 1447 | // Look at the file. (Not found isn't a failure for remount, or for |
| 1446 | // a synthetic filesystem like proc or sysfs.) | 1448 | // a synthetic filesystem like proc or sysfs.) |
| 1447 | 1449 | ||
| 1448 | if (!lstat(mp->mnt_fsname, &st) && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) | 1450 | if (!lstat(mp->mnt_fsname, &st) |
| 1449 | { | 1451 | && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)) |
| 1452 | ) { | ||
| 1450 | // Do we need to allocate a loopback device for it? | 1453 | // Do we need to allocate a loopback device for it? |
| 1451 | 1454 | ||
| 1452 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { | 1455 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { |
| @@ -1474,10 +1477,9 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
| 1474 | 1477 | ||
| 1475 | if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) | 1478 | if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) |
| 1476 | rc = mount_it_now(mp, vfsflags, filteropts); | 1479 | rc = mount_it_now(mp, vfsflags, filteropts); |
| 1477 | |||
| 1478 | // Loop through filesystem types until mount succeeds or we run out | ||
| 1479 | |||
| 1480 | else { | 1480 | else { |
| 1481 | // Loop through filesystem types until mount succeeds | ||
| 1482 | // or we run out | ||
| 1481 | 1483 | ||
| 1482 | /* Initialize list of block backed filesystems. This has to be | 1484 | /* Initialize list of block backed filesystems. This has to be |
| 1483 | * done here so that during "mount -a", mounts after /proc shows up | 1485 | * done here so that during "mount -a", mounts after /proc shows up |
| @@ -1612,9 +1614,9 @@ int mount_main(int argc, char **argv) | |||
| 1612 | 1614 | ||
| 1613 | // If we have a shared subtree flag, don't worry about fstab or mtab. | 1615 | // If we have a shared subtree flag, don't worry about fstab or mtab. |
| 1614 | 1616 | ||
| 1615 | if (ENABLE_FEATURE_MOUNT_FLAGS && | 1617 | if (ENABLE_FEATURE_MOUNT_FLAGS |
| 1616 | (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))) | 1618 | && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) |
| 1617 | { | 1619 | ) { |
| 1618 | rc = mount("", argv[0], "", i, ""); | 1620 | rc = mount("", argv[0], "", i, ""); |
| 1619 | if (rc) bb_perror_msg_and_die("%s", argv[0]); | 1621 | if (rc) bb_perror_msg_and_die("%s", argv[0]); |
| 1620 | goto clean_up; | 1622 | goto clean_up; |
