Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.clump: Fix unchecked return value from lseek #4151

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions raster/r.clump/clump.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <grass/raster.h>
#include <grass/glocale.h>
#include "local_proto.h"
#include <errno.h>
#include <string.h>

#define INCR 1024

Expand Down Expand Up @@ -92,7 +94,9 @@ static CELL do_renumber(int *in_fd, DCELL *rng, int nin, int diag, int minsize,
G_percent(row, nrows, 2);

coffset = (off_t)row * csize;
lseek(cfd, coffset, SEEK_SET);
if (lseek(cfd, coffset, SEEK_SET) == -1) {
G_fatal_error(_("Unable to seek: %s"), strerror(errno));
}
if (read(cfd, cur_clump, csize) != csize)
G_fatal_error(_("Unable to read from temp file"));

Expand All @@ -108,7 +112,9 @@ static CELL do_renumber(int *in_fd, DCELL *rng, int nin, int diag, int minsize,
temp_clump++;
}
if (do_write) {
lseek(cfd, coffset, SEEK_SET);
if (lseek(cfd, coffset, SEEK_SET) == -1) {
G_fatal_error(_("Unable to seek: %s"), strerror(errno));
}
if (write(cfd, cur_clump, csize) != csize)
G_fatal_error(_("Unable to write to temp file"));
}
Expand Down
Loading