components/net-snmp/sun/agent/modules/seaExtensions/sunSystem.c
changeset 882 e80d1fd74c8a
parent 252 ee0fb1eabcbf
--- a/components/net-snmp/sun/agent/modules/seaExtensions/sunSystem.c	Wed Jun 20 02:45:16 2012 -0700
+++ b/components/net-snmp/sun/agent/modules/seaExtensions/sunSystem.c	Wed Jun 20 16:24:55 2012 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  *
  * U.S. Government Rights - Commercial software. Government users are subject
  * to the Sun Microsystems, Inc. standard license agreement and applicable
@@ -83,8 +83,11 @@
     case MODE_GET:
         motd[0] = '\0';
         fd = fopen("/etc/motd", "r");
-        fgets(motd, sizeof (motd), fd);
-        fclose(fd);
+
+	if (fd != NULL) {
+	    fgets(motd, sizeof (motd), fd);
+	    fclose(fd);
+	}
 
         snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
                                 (u_char *) motd, strlen(motd));