#include <string.h>
#endif /* HAVE_STRING_H */
+#define xstrncpy(d_,s_,l_) \
+ do { \
+ char* dst_=d_; \
+ dst_[0]='\0'; \
+ strncat((dst_),(s_),(l_)-1); \
+ } while(0)
+
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
!defined(INTERNET_DOMAIN_SOCKETS)
}
/* if */
msgctl(ipc_qid, IPC_STAT, &msg_st);
- strncpy(buf, msgp->mtext, len);
- /* terminate buf */
- buf[len] = '\0';
+ xstrncpy(buf, msgp->mtext, sizeof(buf));
printf("%d %s", ipc_qid, buf);
fflush(stdout);