Skip to content

Commit

Permalink
remove [f]printf calls from the notify codepaths
Browse files Browse the repository at this point in the history
We can not assume fd 1 and 2 are safe to write to or even exist.

Signed-off-by: Ronnie Sahlberg <[email protected]>
  • Loading branch information
sahlberg committed Jan 3, 2025
1 parent a4e23f5 commit a990931
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ socklen_t *optlen)
#ifdef __GC__
return net_getsockopt(sockfd, level, optname, optval, (socklen_t)optlen);
#else
printf("not yet supported");
return 0;
#endif

Expand Down
12 changes: 6 additions & 6 deletions lib/libsmb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2877,15 +2877,15 @@ notify_change_cb(struct smb2_context *smb2, int status,
struct smb2_file_notify_change_information *fnc = calloc(1, sizeof(struct smb2_file_notify_change_information));

if (status) {
printf("notify_change_cb failed (%s) %s\n",
strerror(-status), smb2_get_error(smb2));
smb2_set_error(smb2, "notify_change_cb failed (%s) %s\n",
strerror(-status), smb2_get_error(smb2));
}

vec.buf = rep->output;
vec.len = rep->output_buffer_length;

if (smb2_decode_filenotifychangeinformation(smb2, fnc, &vec, 0)) {
printf("Failed to decode file notify change information\n");
smb2_set_error(smb2, "Failed to decode file notify change information\n");
}

if (notify_change_data->cb) {
Expand Down Expand Up @@ -2914,7 +2914,7 @@ int smb2_notify_change_filehandle_async(struct smb2_context *smb2, struct smb2fh

notify_change_cb_data = calloc(1, sizeof(struct notify_change_cb_data));
if (notify_change_cb_data == NULL) {
fprintf(stderr, "Failed to allocate notify_change_data");
smb2_set_error(smb2, "Failed to allocate notify_change_data");
return -1;
}
memset(notify_change_cb_data, 0, sizeof(struct notify_change_cb_data));
Expand All @@ -2937,7 +2937,7 @@ int smb2_notify_change_filehandle_async(struct smb2_context *smb2, struct smb2fh
pdu = smb2_cmd_change_notify_async(smb2, &ch_req,
notify_change_cb, notify_change_cb_data);
if (pdu == NULL) {
fprintf(stderr, "Failed to create change_notify command\n");
smb2_set_error(smb2, "Failed to create change_notify command\n");
free(notify_change_cb_data);
return -1;
}
Expand All @@ -2956,7 +2956,7 @@ int smb2_notify_change_async(struct smb2_context *smb2, const char *path, uint16
fh = smb2_open(smb2, path, 0);
#endif
if (fh == NULL) {
printf("smb2_open failed. %s\n", smb2_get_error(smb2));
smb2_set_error(smb2, "smb2_open failed. %s\n", smb2_get_error(smb2));
return -1;
}
return smb2_notify_change_filehandle_async(smb2, fh, flags, filter, loop, cb, cb_data);
Expand Down

0 comments on commit a990931

Please sign in to comment.