diff options
-rw-r--r-- | lib/parseopt.c | 5 | ||||
-rw-r--r-- | lib/sockmapstr.c | 2 | ||||
-rw-r--r-- | lib/stream.c | 4 | ||||
-rw-r--r-- | modules/ldap/ldap.c | 23 | ||||
-rw-r--r-- | src/smapc.c | 2 | ||||
-rw-r--r-- | src/userprivs.c | 2 |
6 files changed, 15 insertions, 23 deletions
diff --git a/lib/parseopt.c b/lib/parseopt.c index cc0c9a6..cf5319d 100644 --- a/lib/parseopt.c +++ b/lib/parseopt.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* This file is part of Smap. | 1 | /* This file is part of Smap. |
2 | Copyright (C) 2008, 2010, 2014 Sergey Poznyakoff | 2 | Copyright (C) 2008, 2010, 2014, 2017 Sergey Poznyakoff |
3 | 3 | ||
4 | Smap is free software; you can redistribute it and/or modify | 4 | Smap is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; either version 3, or (at your option) | 6 | the Free Software Foundation; either version 3, or (at your option) |
7 | any later version. | 7 | any later version. |
8 | 8 | ||
@@ -17,12 +17,13 @@ | |||
17 | #ifdef HAVE_CONFIG_H | 17 | #ifdef HAVE_CONFIG_H |
18 | # include <config.h> | 18 | # include <config.h> |
19 | #endif | 19 | #endif |
20 | #include <smap/parseopt.h> | 20 | #include <smap/parseopt.h> |
21 | #include <smap/diag.h> | 21 | #include <smap/diag.h> |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <ctype.h> | ||
23 | 24 | ||
24 | static struct smap_option const * | 25 | static struct smap_option const * |
25 | find_opt(struct smap_option const *opt, const char *str, const char **value, | 26 | find_opt(struct smap_option const *opt, const char *str, const char **value, |
26 | int flags) | 27 | int flags) |
27 | { | 28 | { |
28 | size_t len = strlen(str); | 29 | size_t len = strlen(str); |
@@ -172,14 +173,12 @@ smap_parseline(struct smap_option const *opt, const char *line, int flags, | |||
172 | 173 | ||
173 | int | 174 | int |
174 | smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags, | 175 | smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags, |
175 | int *pindex) | 176 | int *pindex) |
176 | { | 177 | { |
177 | int i; | 178 | int i; |
178 | long n; | ||
179 | char *s; | ||
180 | int rc = 0; | 179 | int rc = 0; |
181 | const char *modname = argv[0]; | 180 | const char *modname = argv[0]; |
182 | 181 | ||
183 | for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1; | 182 | for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1; |
184 | i < argc; i++) { | 183 | i < argc; i++) { |
185 | char *errmsg; | 184 | char *errmsg; |
diff --git a/lib/sockmapstr.c b/lib/sockmapstr.c index 1c0d749..7e188f2 100644 --- a/lib/sockmapstr.c +++ b/lib/sockmapstr.c | |||
@@ -224,13 +224,13 @@ read_payload_length(struct sockmap_input_stream *sp) | |||
224 | strerror(errno))); | 224 | strerror(errno))); |
225 | return errno; | 225 | return errno; |
226 | } | 226 | } |
227 | if (n == 0) | 227 | if (n == 0) |
228 | return EOF; | 228 | return EOF; |
229 | len += n; | 229 | len += n; |
230 | if (p = memchr(sp->nbuf, ':', len)) { | 230 | if ((p = memchr(sp->nbuf, ':', len))) { |
231 | sp->cp = p - sp->nbuf; | 231 | sp->cp = p - sp->nbuf; |
232 | sp->nbuf[len] = 0; | 232 | sp->nbuf[len] = 0; |
233 | sp->nlen = len; | 233 | sp->nlen = len; |
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | } | 236 | } |
diff --git a/lib/stream.c b/lib/stream.c index d039c08..c217ca6 100644 --- a/lib/stream.c +++ b/lib/stream.c | |||
@@ -222,18 +222,18 @@ _stream_flush_buffer(struct _smap_stream *stream, int all) | |||
222 | if (rc) | 222 | if (rc) |
223 | return rc; | 223 | return rc; |
224 | _stream_advance_buffer(stream, size); | 224 | _stream_advance_buffer(stream, size); |
225 | } | 225 | } |
226 | if (stream->level) { | 226 | if (stream->level) { |
227 | if (all) { | 227 | if (all) { |
228 | if (rc = _force_flush_buffer(stream)) | 228 | if ((rc = _force_flush_buffer(stream))) |
229 | return rc; | 229 | return rc; |
230 | } else if (BUFFER_FULL_P(stream)) { | 230 | } else if (BUFFER_FULL_P(stream)) { |
231 | if (stream->flags & SMAP_STREAM_EXPBUF) | 231 | if (stream->flags & SMAP_STREAM_EXPBUF) |
232 | return _stream_realloc_buffer(stream, 0); | 232 | return _stream_realloc_buffer(stream, 0); |
233 | if (rc = _force_flush_buffer(stream)) | 233 | if ((rc = _force_flush_buffer(stream))) |
234 | return rc; | 234 | return rc; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } else if (all) | 238 | } else if (all) |
239 | _stream_advance_buffer(stream, stream->level); | 239 | _stream_advance_buffer(stream, stream->level); |
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c index d686f6b..b34c560 100644 --- a/modules/ldap/ldap.c +++ b/modules/ldap/ldap.c | |||
@@ -105,13 +105,13 @@ argz_copy(char ***dst, char **a) | |||
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | for (n = 0; a[n]; n++) | 108 | for (n = 0; a[n]; n++) |
109 | ; | 109 | ; |
110 | 110 | ||
111 | b = calloc(i + 1, sizeof(b[0])); | 111 | b = calloc(n + 1, sizeof(b[0])); |
112 | if (!b) | 112 | if (!b) |
113 | return -1; | 113 | return -1; |
114 | for (i = 0; i < n; i++) { | 114 | for (i = 0; i < n; i++) { |
115 | b[i] = strdup(a[i]); | 115 | b[i] = strdup(a[i]); |
116 | if (!b[i]) | 116 | if (!b[i]) |
117 | return -1; | 117 | return -1; |
@@ -197,13 +197,13 @@ parse_ldap_conf(const char *name, struct smap_option const *opt) | |||
197 | smap_error("can't open LDAP config file %s: %s", | 197 | smap_error("can't open LDAP config file %s: %s", |
198 | name, strerror(errno)); | 198 | name, strerror(errno)); |
199 | return -1; | 199 | return -1; |
200 | } | 200 | } |
201 | 201 | ||
202 | line = 0; | 202 | line = 0; |
203 | while (p = fgets(buf, sizeof(buf), fp)) { | 203 | while ((p = fgets(buf, sizeof(buf), fp))) { |
204 | size_t len; | 204 | size_t len; |
205 | char *errmsg; | 205 | char *errmsg; |
206 | 206 | ||
207 | ++line; | 207 | ++line; |
208 | 208 | ||
209 | while (*p && isspace(*p)) | 209 | while (*p && isspace(*p)) |
@@ -251,20 +251,22 @@ parse_ldap_conf(const char *name, struct smap_option const *opt) | |||
251 | } | 251 | } |
252 | 252 | ||
253 | fclose(fp); | 253 | fclose(fp); |
254 | return rc; | 254 | return rc; |
255 | } | 255 | } |
256 | 256 | ||
257 | #if 0 | ||
257 | static int | 258 | static int |
258 | readconf(struct smap_option const *opt, const char *val, char **errmsg) | 259 | readconf(struct smap_option const *opt, const char *val, char **errmsg) |
259 | { | 260 | { |
260 | int rc = parse_ldap_conf(val, opt); | 261 | int rc = parse_ldap_conf(val, opt); |
261 | if (rc) | 262 | if (rc) |
262 | *errmsg = "parse error"; | 263 | *errmsg = "parse error"; |
263 | return rc; | 264 | return rc; |
264 | } | 265 | } |
266 | #endif | ||
265 | 267 | ||
266 | #define MKOPT_DEFAULT 0 | 268 | #define MKOPT_DEFAULT 0 |
267 | #define MKOPT_REUSE 0x01 | 269 | #define MKOPT_REUSE 0x01 |
268 | #define MKOPT_RESET 0x02 | 270 | #define MKOPT_RESET 0x02 |
269 | 271 | ||
270 | static int | 272 | static int |
@@ -499,14 +501,12 @@ parse_ldap_uri(const char *uri) | |||
499 | static LDAP * | 501 | static LDAP * |
500 | ldap_connect(struct ldap_conf *conf) | 502 | ldap_connect(struct ldap_conf *conf) |
501 | { | 503 | { |
502 | int rc; | 504 | int rc; |
503 | char *ldapuri = NULL; | 505 | char *ldapuri = NULL; |
504 | LDAP *ld = NULL; | 506 | LDAP *ld = NULL; |
505 | char *val; | ||
506 | unsigned long lval; | ||
507 | 507 | ||
508 | if (ldap_debug_level) { | 508 | if (ldap_debug_level) { |
509 | if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, | 509 | if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, |
510 | &ldap_debug_level) | 510 | &ldap_debug_level) |
511 | != LBER_OPT_SUCCESS ) | 511 | != LBER_OPT_SUCCESS ) |
512 | smap_error("cannot set LBER_OPT_DEBUG_LEVEL %d", | 512 | smap_error("cannot set LBER_OPT_DEBUG_LEVEL %d", |
@@ -602,39 +602,37 @@ full_read(int fd, char *file, char *buf, size_t size) | |||
602 | return 0; | 602 | return 0; |
603 | } | 603 | } |
604 | 604 | ||
605 | static int | 605 | static int |
606 | get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc) | 606 | get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc) |
607 | { | 607 | { |
608 | char *file; | ||
609 | |||
610 | if (conf->bindpwfile) { | 608 | if (conf->bindpwfile) { |
611 | struct stat st; | 609 | struct stat st; |
612 | int fd, rc; | 610 | int fd, rc; |
613 | char *mem, *p; | 611 | char *mem, *p; |
614 | 612 | ||
615 | fd = open(file, O_RDONLY); | 613 | fd = open(conf->bindpwfile, O_RDONLY); |
616 | if (fd == -1) { | 614 | if (fd == -1) { |
617 | smap_error("can't open password file %s: %s", | 615 | smap_error("can't open password file %s: %s", |
618 | file, strerror(errno)); | 616 | conf->bindpwfile, strerror(errno)); |
619 | return -1; | 617 | return -1; |
620 | } | 618 | } |
621 | if (fstat(fd, &st)) { | 619 | if (fstat(fd, &st)) { |
622 | smap_error("can't stat password file %s: %s", | 620 | smap_error("can't stat password file %s: %s", |
623 | file, strerror(errno)); | 621 |