mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-11-21 10:56:10 +00:00
Merge pull request #133 from xrmx/coverity3
Fix "argument cannot be negative" errors reported by Coverity
This commit is contained in:
+6
-6
@@ -458,13 +458,13 @@ void uwsgi_check_logrotate(void) {
|
||||
uwsgi_error_open(uwsgi.logfile);
|
||||
grace_them_all(0);
|
||||
}
|
||||
if (dup2(fd, uwsgi.original_log_fd) < 0) {
|
||||
uwsgi_error("dup2()");
|
||||
grace_them_all(0);
|
||||
else {
|
||||
if (dup2(fd, uwsgi.original_log_fd) < 0) {
|
||||
uwsgi_error("dup2()");
|
||||
grace_them_all(0);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
}
|
||||
else {
|
||||
uwsgi_error("unable to rotate log: rename()");
|
||||
|
||||
+14
-12
@@ -460,18 +460,20 @@ void uwsgi_as_root() {
|
||||
}
|
||||
}
|
||||
int additional_groups = getgroups(0, NULL);
|
||||
gid_t *gids = uwsgi_calloc(sizeof(gid_t) * additional_groups);
|
||||
int i;
|
||||
if (getgroups(additional_groups, gids) > 0) {
|
||||
for (i = 0; i < additional_groups; i++) {
|
||||
if (gids[i] == uwsgi.gid)
|
||||
continue;
|
||||
struct group *gr = getgrgid(gids[i]);
|
||||
if (gr) {
|
||||
uwsgi_log("set additional group %d (%s)\n", gids[i], gr->gr_name);
|
||||
}
|
||||
else {
|
||||
uwsgi_log("set additional group %d\n", gids[i]);
|
||||
if (additional_groups > 0) {
|
||||
gid_t *gids = uwsgi_calloc(sizeof(gid_t) * additional_groups);
|
||||
if (getgroups(additional_groups, gids) > 0) {
|
||||
int i;
|
||||
for (i = 0; i < additional_groups; i++) {
|
||||
if (gids[i] == uwsgi.gid)
|
||||
continue;
|
||||
struct group *gr = getgrgid(gids[i]);
|
||||
if (gr) {
|
||||
uwsgi_log("set additional group %d (%s)\n", gids[i], gr->gr_name);
|
||||
}
|
||||
else {
|
||||
uwsgi_log("set additional group %d\n", gids[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -4035,7 +4035,7 @@ void uwsgi_opt_connect_and_read(char *opt, char *address, void *foobar) {
|
||||
char buf[8192];
|
||||
|
||||
int fd = uwsgi_connect(address, -1, 0);
|
||||
for (;;) {
|
||||
while (fd >= 0) {
|
||||
int ret = uwsgi_waitfd(fd, -1);
|
||||
if (ret <= 0) {
|
||||
exit(0);
|
||||
@@ -4046,6 +4046,8 @@ void uwsgi_opt_connect_and_read(char *opt, char *address, void *foobar) {
|
||||
}
|
||||
uwsgi_log("%.*s", (int) len, buf);
|
||||
}
|
||||
uwsgi_error("uwsgi_connect()");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void uwsgi_opt_extract(char *opt, char *address, void *foobar) {
|
||||
|
||||
@@ -1802,7 +1802,7 @@ void uwsgi_python_harakiri(int wid) {
|
||||
char *address = uwsgi_concat2(up.tracebacker, uwsgi_num2str(wid));
|
||||
|
||||
int fd = uwsgi_connect(address, -1, 0);
|
||||
for (;;) {
|
||||
while (fd >= 0) {
|
||||
int ret = uwsgi_waitfd(fd, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT]);
|
||||
if (ret <= 0) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user