summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-12-10 15:11:23 +0100
committerGünther Deschner <gd@samba.org>2012-12-12 15:00:02 +0100
commitb4884dcff7362d585d93c3acf08e8c4835d918d0 (patch)
tree0e0d01235dcb054704e6c4029db91e1906bd2f81
parentb4accd365d4758f3f4453083c24c59615051d863 (diff)
downloadsamba-b4884dcff7362d585d93c3acf08e8c4835d918d0.tar.gz
samba-b4884dcff7362d585d93c3acf08e8c4835d918d0.tar.bz2
samba-b4884dcff7362d585d93c3acf08e8c4835d918d0.zip
s3-libsmb: Fix possible comparsion problems.
This makes the code also easier to understand. Found by Coverity. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Günther Deschner <gd@samba.org>
-rw-r--r--source3/libsmb/libsmb_printjob.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c
index db46ceee9c..173fa327d3 100644
--- a/source3/libsmb/libsmb_printjob.c
+++ b/source3/libsmb/libsmb_printjob.c
@@ -93,6 +93,8 @@ SMBC_print_file_ctx(SMBCCTX *c_file,
{
SMBCFILE *fid1;
SMBCFILE *fid2;
+ smbc_open_fn f_open1;
+ smbc_open_print_job_fn f_open_pj2;
int bytes;
int saverr;
int tot_bytes = 0;
@@ -113,18 +115,30 @@ SMBC_print_file_ctx(SMBCCTX *c_file,
}
/* Try to open the file for reading ... */
+ f_open1 = smbc_getFunctionOpen(c_file);
+ if (f_open1 == NULL) {
+ errno = EINVAL;
+ TALLOC_FREE(frame);
+ return -1;
+ }
- if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname,
- O_RDONLY, 0666)) < 0) {
- DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno));
+ fid1 = f_open1(c_file, fname, O_RDONLY, 0666);
+ if (fid1 < 0) {
+ DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno));
TALLOC_FREE(frame);
- return -1; /* smbc_open sets errno */
- }
+ return -1; /* smbc_open sets errno */
+ }
/* Now, try to open the printer file for writing */
+ f_open_pj2 = smbc_getFunctionOpenPrintJob(c_print);
+ if (f_open_pj2 == NULL) {
+ errno = EINVAL;
+ TALLOC_FREE(frame);
+ return -1;
+ }
- if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print,
- printq)) < 0) {
+ fid2 = f_open_pj2(c_print, printq);
+ if (fid2 < 0) {
saverr = errno; /* Save errno */
smbc_getFunctionClose(c_file)(c_file, fid1);
errno = saverr;