]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Added uchar_empty_ptr and use it instead of &uchar_nul.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 19 Aug 2016 10:15:09 +0000 (13:15 +0300)
committerGitLab <gitlab@git.dovecot.net>
Tue, 23 Aug 2016 10:53:38 +0000 (13:53 +0300)
This makes Coverity happier about not treating a char as an array.
For now this is a pointer to a 0, but could as well become a pointer
that crashes if dereferenced. Shouldn't be NULL anyway because clang's
-fsanitize=nonnull-attribute will complain about them.

src/auth/auth-master-connection.c
src/auth/auth-request-handler.c
src/auth/auth-request.c
src/auth/mech.c
src/auth/userdb-static.c
src/lib-imap/imap-parser.c
src/lib-sasl/mech-login.c
src/lib/istream.c
src/lib/strfuncs.c
src/lib/strfuncs.h

index 804b0d0229c94a0fc85c856ee2d0c3b82603e86e..ebefe5faa632cbfc33a971c4d6ca31160c949139 100644 (file)
@@ -419,14 +419,14 @@ master_input_pass(struct auth_master_connection *conn, const char *args)
                        return FALSE;
                auth_request_log_info(auth_request, "passdb", "%s", error);
                pass_callback(PASSDB_RESULT_USER_UNKNOWN,
-                             &uchar_nul, 0, auth_request);
+                             uchar_empty_ptr, 0, auth_request);
        } else if (conn->userdb_restricted_uid != 0) {
                /* no permissions to do this lookup */
                auth_request_log_error(auth_request, "passdb",
                        "Auth client doesn't have permissions to do "
                        "a PASS lookup: %s", auth_restricted_reason(conn));
                pass_callback(PASSDB_RESULT_INTERNAL_FAILURE,
-                             &uchar_nul, 0, auth_request);
+                             uchar_empty_ptr, 0, auth_request);
        } else {
                auth_request_set_state(auth_request,
                                       AUTH_REQUEST_STATE_MECH_CONTINUE);
index d329a82eeeb2e00664a5095867ce3aff49522830..f1ce54518f2b35f1cd05c1007014fdd13887653c 100644 (file)
@@ -829,7 +829,7 @@ void auth_request_handler_flush_failures(bool flush_all)
                i_assert(auth_request->state == AUTH_REQUEST_STATE_FINISHED);
                auth_request_handler_reply(auth_request,
                                           AUTH_CLIENT_RESULT_FAILURE,
-                                          &uchar_nul, 0);
+                                          uchar_empty_ptr, 0);
                auth_request_unref(&auth_request);
        }
 }
index 56b5a3d09243b3553918f8873640916deeeb3346..63961194ae3ebe59604c475ea240d401f09d9b1d 100644 (file)
@@ -1116,7 +1116,7 @@ void auth_request_lookup_credentials_policy_continue(struct auth_request *reques
                        "passdb doesn't support credential lookups");
                auth_request_lookup_credentials_callback(
                                        PASSDB_RESULT_SCHEME_NOT_AVAILABLE,
-                                       &uchar_nul, 0, request);
+                                       uchar_empty_ptr, 0, request);
        } else if (passdb->passdb->blocking) {
                passdb_blocking_lookup_credentials(request);
        } else {
index 39927bb7903a0b3a75fefb117a6434549a5b4f82..001deecffd390448ff57447523ed4ba96179fb27 100644 (file)
@@ -50,7 +50,7 @@ void mech_generic_auth_initial(struct auth_request *request,
                               const unsigned char *data, size_t data_size)
 {
        if (data == NULL) {
-               auth_request_handler_reply_continue(request, &uchar_nul, 0);
+               auth_request_handler_reply_continue(request, uchar_empty_ptr, 0);
        } else {
                /* initial reply given, even if it was 0 bytes */
                request->mech->auth_continue(request, data, data_size);
index bf8c9af093e0508845d0aa819371ed744fbac495..5578512300454ffe2bad5e30abf806573a5f2509 100644 (file)
@@ -101,7 +101,7 @@ static void static_lookup(struct auth_request *auth_request,
                } else {
                        static_credentials_callback(
                                PASSDB_RESULT_SCHEME_NOT_AVAILABLE,
-                               &uchar_nul, 0, auth_request);
+                               uchar_empty_ptr, 0, auth_request);
                }
        } else {
                static_lookup_real(auth_request, callback);
index 8715e310ee47db3efb97535a0f5f0ade5986b6fc..6fb21f366ac6d123a99f67c448b27c6855ef86a3 100644 (file)
@@ -516,7 +516,7 @@ static bool imap_parser_read_literal_data(struct imap_parser *parser,
        } else {
                /* we want to save only literal size, not the literal itself. */
                parser->literal_size_return = TRUE;
-               imap_parser_save_arg(parser, &uchar_nul, 0);
+               imap_parser_save_arg(parser, uchar_empty_ptr, 0);
                return FALSE;
        }
 }
index daae7e32fde7f43944e9f71a74fbb575c69b6054..4c202ab89635a6d57c716c82d345aaef303711b6 100644 (file)
@@ -51,7 +51,7 @@ mech_login_output(struct dsasl_client *_client,
 
        switch (client->state) {
        case STATE_INIT:
-               *output_r = &uchar_nul;
+               *output_r = uchar_empty_ptr;
                *output_len_r = 0;
                return 0;
        case STATE_USER:
index b08ae4f3c80b63d954de16629c0ea7d36999e708..d26e119618299fdc9cacf547ef252b722bb39b04 100644 (file)
@@ -503,7 +503,7 @@ i_stream_get_data(struct istream *stream, size_t *size_r)
 
        if (_stream->skip >= _stream->pos) {
                *size_r = 0;
-               return &uchar_nul;
+               return uchar_empty_ptr;
        }
 
        if (i_stream_is_buffer_invalid(_stream)) {
@@ -528,7 +528,7 @@ i_stream_get_data(struct istream *stream, size_t *size_r)
                        _stream->skip = _stream->pos = 0;
                        stream->eof = FALSE;
                }
-               return &uchar_nul;
+               return uchar_empty_ptr;
        }
 
         *size_r = _stream->pos - _stream->skip;
index 5467facaa55bdaf210d070285a9d2c0b89a383a2..4ca9c01ee73082be06add239442df707c3cb01b3 100644 (file)
@@ -19,6 +19,7 @@ enum _str_trim_sides {
 };
 
 const unsigned char uchar_nul = '\0';
+const unsigned char *uchar_empty_ptr = { 0 };
 
 int i_snprintf(char *dest, size_t max_chars, const char *format, ...)
 {
index 836c210d75b3ae48dbae1dc460efb52c502540de..338fd7a8c85aa241a4bbbbeeca8596a21cfa655c 100644 (file)
@@ -4,6 +4,7 @@
 #define MAX_INT_STRLEN ((sizeof(uintmax_t) * CHAR_BIT + 2) / 3 + 1)
 
 extern const unsigned char uchar_nul; /* (const unsigned char *)"" */
+extern const unsigned char *uchar_empty_ptr; /* non-NULL pointer that shouldn't be dereferenced. */
 
 /* Returns -1 if dest wasn't large enough, 0 if not. */
 int i_snprintf(char *dest, size_t max_chars, const char *format, ...)