]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - lib/smblib/smb-errors.c
SourceFormat Enforcement
[thirdparty/squid.git] / lib / smblib / smb-errors.c
index 0c0d94c91f021e559c8a67e8d7e559f50bf91132..2409fb4d2b0a81e97614660a00a3d76d977d5824 100644 (file)
@@ -1,10 +1,17 @@
+/*
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 /* UNIX SMBlib NetBIOS implementation
 
    Version 1.0
    SMBlib Error values etc ...
 
    Copyright (C) Richard Sharpe, Andrew Tridgell, and Merik Karman, 1996
-
 */
 
 /*
@@ -29,8 +36,7 @@
 /* ensure we don't overwrite strings when not passed enough space. Also */
 /* added code to say unknown error codes if we see any                  */
 
-
-#include <stdio.h>
+#include "squid.h"
 
 typedef struct {
     char *name;
@@ -189,7 +195,7 @@ int SMB_Get_SMB_Error_Msg(int err_class, int err_code, char *msg_buf, int len)
 
                 strncpy(msg_buf, err_classes[i].class, len);
                 strncat(msg_buf, " - ", len - strlen(msg_buf));
-                sprintf(internal_buf, "%d", err_code);
+                snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_code);
                 strncat(msg_buf, internal_buf, len - strlen(msg_buf));
                 strncat(msg_buf, " (Unknown error code).", len - strlen(msg_buf));
 
@@ -199,7 +205,7 @@ int SMB_Get_SMB_Error_Msg(int err_class, int err_code, char *msg_buf, int len)
 
                 strncpy(msg_buf, err_classes[i].class, len);
                 strncat(msg_buf, " - ", len - strlen(msg_buf));
-                sprintf(internal_buf, "%d", err_code);
+                snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_code);
                 strncat(msg_buf, internal_buf, len - strlen(msg_buf));
 
                 return(strlen(msg_buf));
@@ -210,13 +216,14 @@ int SMB_Get_SMB_Error_Msg(int err_class, int err_code, char *msg_buf, int len)
 
     /* If we get here, we did not recognize the error class */
 
-    sprintf(internal_buf, "%d", err_class);
+    snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_class);
     strncat(msg_buf, internal_buf, len - strlen(msg_buf));
     strncat(msg_buf, " (Unknown Error Class) - ", len - strlen(msg_buf));
-    sprintf(internal_buf, "%d", err_code);
+    snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_code);
     strncat(msg_buf, internal_buf, len - strlen(msg_buf));
     strncat(msg_buf, "(error code).", len - strlen(msg_buf));
 
     return(strlen(msg_buf));
 
 }
+