]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - lib/smblib/smb-errors.c
SourceFormat Enforcement
[thirdparty/squid.git] / lib / smblib / smb-errors.c
index c48ee3195c5e124445c464af07d78b467c29ede7..2409fb4d2b0a81e97614660a00a3d76d977d5824 100644 (file)
@@ -1,4 +1,10 @@
-#include "config.h"
+/*
+ * 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
 
@@ -6,7 +12,6 @@
    SMBlib Error values etc ...
 
    Copyright (C) Richard Sharpe, Andrew Tridgell, and Merik Karman, 1996
-
 */
 
 /*
@@ -31,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;
@@ -191,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));
 
@@ -201,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));
@@ -212,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));
 
 }
+